我有一个像这样的json文件:
["Sylvia Molloy","Manuel Mujica Lainez","Gustavo Nielsen","Silvina Ocampo","Victoria Ocampo","Hector German Oesterheld", "Olga
Orozco","Juan L. Ortiz", "Alicia Partnoy","Roberto Payro","Ricardo Piglia","Felipe Pigna","Alejandra Pizarnik",
"Antonio Porchia", "Juan Carlos Portantiero","Manuel Puig","Andres Rivera","Mario Rodriguez Cobos","Arturo Andres
Roig","Ricardo Rojas"]
我在浏览器控制台中收到语法错误,有人知道为什么吗?
我已将我的json文件编辑为:[“SylviaMolloy”,“Bassemalam”]并且我发布了错误图片,请再次检查
答案 0 :(得分:0)
在控制台中,您不应在字符串中使用新行。它们在数组元素之间很好。
答案 1 :(得分:0)
Javascript字符串字面上不能有行终止符。你有:
"Arturo Andres //<-- line terminator here is illegal
Roig"
应该是
"Arturo Andres Roig", ...
或者
"Arturo Andres\nRoig", ...
答案 2 :(得分:0)
你应该在花括号{}之间包装响应,并给它一个键,使它是一个有效的JSON:{ "people" : ["Sylvia Molloy","Manuel Mujica Lainez"] }