可以使用JSON.parse()方法将JSON字符串转换成JSON对象,示例如下:
JSON.parse()
var jsonString = '{"name":"John", "age":30, "city":"New York"}'; var jsonObject = JSON.parse(jsonString); console.log(jsonObject);
输出结果:
{ name: "John", age: 30, city: "New York" }