Eval() = Unexpected token : error

前端 未结 8 1822
囚心锁ツ
囚心锁ツ 2020-12-09 04:28

I tried this simple JavaScript code:

eval(\'{\"Topics\":[\"toto\",\"tata\",\"titi\"]}\')

In the Chrome console, for example, this returns

8条回答
  •  星月不相逢
    2020-12-09 04:58

    You have to write like this

    eval('('+stingJson+')' );
    

    to convert an string to Object

    Hope I help!

提交回复
热议问题