I'm getting an error [Exception: SyntaxError: Unexpected token :]
when I try to evaluate the following expression:
eval("{"T1": [1,2,3,4,5,6,7,8,9,10,11,12], "T2": [12,11,10,9,8,7,5,4,3,2,1]}")
However, the same expression without the "
works:
eval({"T1": [1,2,3,4,5,6,7,8,9,10,11,12], "T2": [12,11,10,9,8,7,5,4,3,2,1]})
If my JSON is in string format, like in the first example, how can I convert it into a javascript object?
If I try using:
JSON.parse("{"T1": [1,2,3,4,5,6,7,8,9,10,11,12], "T2": [12,11,10,9,8,7,5,4,3,2,1]}")
I get [Exception: SyntaxError: Unexpected identifier]
. How can I escape the "
?