json解析 JSON.parse(‘{“p”: 5}’, function(k, v){})
var jsonstr = '[{"name":"王","age":62},{"name":"晓","age":69},{"name":"栋","age":45}]'
var jsonobj = JSON.parse(jsonstr,function (key,val) {
if(key == "name") {
return "看"+val
}else {
return val
}
});
json序列化 JSON.stringify(value, replacer, space)
var obj = [
{
name:'看',
age:55
},
{
name:'了',
age:53
},
{
name:'吧',
age:95
}
]
var str = JSON.stringify(obj,['name'],2)
第二个参数是过滤可以写函数,第三个参数是缩进