Unexpected token ' in JSON at position 11 [duplicate]
I have an array in string and I want to convert it to array again , But when I use JSON.parse(data)
, javascrept gives me this error :
Uncaught (in promise) SyntaxError: Unexpected token ' in JSON at position 11
So how can I convert this string to array or fix this error ?
var data = `[
['1','2','3'],
['3','4','5','6']
]`;
var d = JSON.parse(data);
I get this data from an api and I can't change '
to "
Solution 1:
In JSON, strings are delimited with "
(U+0022 : QUOTATION MARK) characters, only "
characters, and never '
(U+0027 : APOSTROPHE) characters.