JSON.parse生成一个SyntaxError

时间:2016-12-02 00:15:32

标签: javascript json

输入:

JSON.parse("{list : []}");

在控制台中生成:

VM9793:1 Uncaught SyntaxError: Unexpected token l in JSON at position 1
at JSON.parse (<anonymous>)
at <anonymous>:1:6

enter image description here

1 个答案:

答案 0 :(得分:6)

JSON要求对象键是stings,所以它必须是:

JSON.parse('{"list" : []}');