Eval() = Unexpected token : error

eval, javascript, json

Solution

FWIW, use `JSON.parse` instead. Safer than `eval`.

Problem

I tried this simple JavaScript code: ``` eval('{"Topics":["toto","tata","titi"]}') ``` In the Chrome console, for example, this returns SyntaxError: Unexpected token : I tried the JSON on JSONLint and it's valid. Do you see the bug?

Original source