var str = ‘{ "name": "cxh", "sex": "man" }‘; //JSON字符串:
var obj = JSON.parse(str);; //由JSON字符串转换为JSON对象
console.log(obj)
var str2 = { "name": "cxh", "sex": "man" }; //JSON对象
var last=JSON.stringify(obj); //将JSON对象转化为JSON字符
console.log(last);
时间: 2024-11-08 12:54:24