JSON转字符串字符串转JSON

mac2025-02-09  13

一、字符串转JSON

JSON字符串:{“type”:“Point”,“coordinates”:[123.2094444,41.20166667]}

JSON.parse(str); //转换后/ {type: "Point", coordinates: Array(2)} coordinates: Array(2) 0: 123.2094444 1: 41.20166667 length: 2 __proto__: Array(0) type: "Point" eval('(' + str + ')'); //转换后 {type: "Point", coordinates: Array(2)} coordinates: Array(2) 0: 123.2094444 1: 41.20166667 length: 2 __proto__: Array(0) type: "Point" __proto__: Object

二、JSON转字符串

JSON.stringify(obj)
最新回复(0)