可以使用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" }