JavaScript JSON解析unescape引号? [英] Javascript JSON parse unescape quotes?
本文介绍了JavaScript JSON解析unescape引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用户输入JSON数据,然后将其保存到其他对象.但是我得到的是dtExport: '{\\"type\\":\\"polyline\\"}
而不是JSON.
I have a user entered JSON data which is then saved to other object. But instead of JSON I get dtExport: '{\\"type\\":\\"polyline\\"}
.
我该如何解决? 谢谢.
How can I fix it? Thanks.
推荐答案
var x ='{\"type \":\"polyline \"}';; x = x.replace(/\"/g," \");
var x = '{\"type\":\"polyline\"}'; x = x.replace(/\"/g, "\"");
和下一个JSON.parse
and next JSON.parse
结果:
"{"type":"polyline"}"
这篇关于JavaScript JSON解析unescape引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文