BranceLee / ES6-NoteBook

I am learn ES6 as a fresh man ,there are some notes when I am learning it
0 stars 0 forks source link

Json 对象与Json 字符串的转化 #4

Open BranceLee opened 6 years ago

BranceLee commented 6 years ago

const a='[{"name":"Tom"}, {"age":"18"}]' //name 与age 必须加上双引号 const b=JSON.parse(a) // [{name:"Tom"} ,{age:"18"}]

JSON的字符串的变量name 都得加上双引号,JSON.stringfy( ) JSON的对象的变量name 不加双引号, JSON.parse( )