标签:str span color logs let eof bsp class code
let obj={ name:‘ww‘; age:22; sex:‘女‘; } let str=JSON.stringify(obj); //{‘name‘:‘ww‘,age:22,sex:‘女‘} console.log(typeof string,string); // string{‘name‘:‘ww‘,age:22,sex:‘女‘}
let obj={ name:‘ww‘; age:22; sex:‘女‘; } let obj1=JSON.parse(string); console.log(typeof obj1,obj); // object{‘name‘:‘ww‘,age:22,sex:‘女‘}
字符串与JSON 的互换:JSON——字符串:JSON.stringify ; 字符串——JSON:JSON.parse
标签:str span color logs let eof bsp class code
原文地址:http://www.cnblogs.com/llying/p/7528929.html