JSON.parse() & JSON.stringify()

原创转载请注明出处:http://agilestyle.iteye.com/blog/2352232

JSON.parse()

Demo 

var str = '{"username":"nodejs", "password":"23"}';

console.log(JSON.parse(str));

Console Output


 

JSON.stringify()

Demo 

var str = {a: 1, b: 2, c: "test"};

console.log(JSON.stringify(str));

Console Output


 

猜你喜欢

转载自agilestyle.iteye.com/blog/2352232