Unable to solve error “ Uncaught SyntaxError: Unexpected token o ”

前端 未结 4 1620
栀梦
栀梦 2020-12-21 13:02

I am currently practicing using Javascript/Dojo. However, I have an error that I am unable to solve:

Uncaught SyntaxError: Unexpected token o

4条回答
  •  清歌不尽
    2020-12-21 13:44

    You're trying to parse a JavaScript object. JSON.parse is for parsing a JSON string representing a JavaScript-like object.

    Just skip the parsing altogether:

    alert(data.list[1].Name);
    

    On a related note: you might be interested in reading There's no such thing as a "JSON Object".

提交回复
热议问题