A bit of an odd question perhaps.
I'm trying to Store a JSON string appropriately in a CSV column as a string. It works OK when generating the CSV file, however parsing the CSV file with the JSON in it is a problem.
I've tried "{"prop": "Val"...}"
, "{""prop"": ""Val""...}"
, "{\"prop\": \"Val\"...}"
, "{\""prop\"": \""Val\""...}"
However none of them parse well at all.
Please help!
The correct answer here is to double quote the JSON string so this:
{ "a": 10 }
converts into this:
"{ ""a"": 10 }"
You can use the following replace logic to escape your JSON string:
`"${YOUR_JSON_STR.replace(/\"/g, '""')}"`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With