2

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.

fivepointseven
  • 1,041
  • 2
  • 11
  • 23

1 Answers1

5

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

and next JSON.parse

results:

"{"type":"polyline"}"
Disputed
  • 80
  • 8
  • Doesn't work :( I have `var planJson = JSON.parse(message.text)` And then saving to DB: `db.merge('plans', planId, { "dtExport": JSON.stringify(planJson) })` But it's still the same. – fivepointseven Jul 26 '15 at 19:28
  • @fivepointseven My answer was edited by Mateusz and it seems to be working fine now. – Disputed Jul 26 '15 at 19:34