调试语句

JSON.parse(text [, reviver]) //字符串到js对象

JSON.stringify(value [, replacer] [, space]) //js对象到字符串



var a='{"k1":"v1","k2":"v2","k3":"v3"}'

var r=JSON.parse(a,function(key,value){console.log(key+' >> '+JSON.stringify(value));return value});

//k1 >> "v1"

//k2 >> "v2"

//k3 >> "v3"

// >> {"k1":"v1","k2":"v2","k3":"v3"}





var b={a:'qwe',b:'asd',c:'zxc'}

JSON.stringify(b,function(key,value){console.log(key+' >> '+value);return value;})

 //>> [object Object]

 //a >> qwe

 //b >> asd

 //c >> zxc

//"{"a":"qwe","b":"asd","c":"zxc"}"

 

你可能感兴趣的:(调试)