Javascript JSON parse unescape quotes?

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.

Answers:

Answer

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

and next JSON.parse

results:

"{"type":"polyline"}"

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.