I have a string
str = \"{\'a\':1}\";
JSON.parse(str);
VM514:1 Uncaught SyntaxError: Unexpected token \'(…)
How can I parse the above stri
The JSON standard requires double quotes and will not accept single quotes, nor will the parser.
If you have a simple case with no escaped single quotes in your strings (which would normally be impossible, but this isn't JSON), you can simple str.replace(/'/g, '"')
and you should end up with valid JSON.