How can I convert the string...
"{ name: 'John' }"
...to an actual JavaScript object literal that will allow me to access the data using its keys (I.e. varname["name"] == "John")? I can't use JSON.parse(), since the string is invalid JSON.
How can I convert the string...
...to an actual JavaScript object literal that will allow me to access the data using its keys (I.e. varname["name"] == "John")? I can't use JSON.parse(), since the string is invalid JSON. |
||||
From the previous question
|
|||||
|
You could use eval().
|
|||
|
Example with
|
|||
|
eval
and make the source produce proper JSON. – Thilo 1 hour ago