I tried this simple JavaScript code:
eval(\'{\"Topics\":[\"toto\",\"tata\",\"titi\"]}\')
In the Chrome console, for example, this returns>
Because eval
does not force an expression context and the string provided is an invalid JavaScript program, thus the first three tokens (and how they are looked at) are:
{ // <-- beginning of a block, and NOT an Object literal
"Topics" // <-- string value, okay (note this is NOT a label)
: // <-- huh? expecting ";" or "}" or an operator, etc.
Happy coding.