字符串-->json对象:JSON.parse()
var str = '{"code":"A001","name":"张三"}'; JSON.parse(str); 结果: code: "A001" name: "张三"
json对象-->字符串:JSON.stringify()
var obj = {code:"A001",name:"张三"}; JSON.stringify(obj); 结果: "{"code":"A001","name":"张三"}"
字符串-->json对象:JSON.parse()
var str = '{"code":"A001","name":"张三"}'; JSON.parse(str); 结果: code: "A001" name: "张三"
json对象-->字符串:JSON.stringify()
var obj = {code:"A001",name:"张三"}; JSON.stringify(obj); 结果: "{"code":"A001","name":"张三"}"