Reputation: 2187
Hi I'm trying to convert a string like this:
{'2': [1], '0': [1]}
to json using JSON.parse in javascript but it keeps saying
Uncaught SyntaxError: Unexpected token '
can anyone help me with this, thanks
Upvotes: 0
Views: 110
Reputation: 580
You need to wrap it with curly braces to make it work. ex. This will work fine.
"{"0":[1],"2":[1]}"
Upvotes: 2