fivepointseven
fivepointseven

Reputation: 1051

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.

Upvotes: 2

Views: 9234

Answers (1)

Disputed
Disputed

Reputation: 80

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

and next JSON.parse

results:

"{"type":"polyline"}"

Upvotes: 5

Related Questions