Javascript JSON 解析 unescape 引号?

fiv*_*ven 2 javascript json escaping

我有一个用户输入了 JSON 数据,然后将其保存到其他对象。但是我得到的不是 JSON dtExport: '{\\"type\\":\\"polyline\\"}

我该如何解决?谢谢。

Dis*_*ted 5

var x = '{\"type\":\"polyline\"}'; x = x.replace(/\"/g, "\"");

和下一个 JSON.parse

结果:

"{"type":"polyline"}"
Run Code Online (Sandbox Code Playgroud)