This string is received from database:
"[{\"country_code\":\"IN\",\"gdpr_fields\":{\"policy\":\"yes\",\"profiling\":\"na\",\"age\":\"yes\",\"subscription\":\"na\"}}]"
I have been trying to convert this string to a JSON value but it always ends up throwing an error
undefined:1
[{\"country_code\":\"IN\",\"gdpr_fields\":{\"policy\":\"yes\",\"profiling\":\"na\",\"age\":\"yes\",\"subscription\":\"na\"}}]
^
Unexpected token \ in JSON at position 2
Is there a way to convert this string to JSON using javascript?
Expected Result:
[{"country_code":"IN","gdpr_fields":{"policy":"yes","profiling":"na","age":"yes","subscription":"na"}}]
JSON.parsecan't handle actual backslashes: jsfiddle.net/egm5vhtu Often databases are connected to many systems and it's not possible to fix all systems at once. A workaround is sometimes necessary.