Eval() = Unexpected token : error
问题 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? 回答1: FWIW, use JSON.parse instead. Safer than eval . 回答2: You have to write like this eval('('+stingJson+')' ); to convert an string to Object Hope I help! 回答3: Because eval does not force an expression context and the string provided is an invalid JavaScript program,