未捕获的语法错误意外令牌U JSON [英] uncaught syntaxerror unexpected token U JSON

查看:81
本文介绍了未捕获的语法错误意外令牌U JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在chrome中运行页面时,出现此错误未捕获的语法错误意外的令牌U".在firefox中,我得到"JSON.parse:意外字符".我正在从php文件返回json数据,并且返回的json字符串有效.我用 http://jsonlint.com/进行了检查.任何帮助将不胜感激...谢谢.

I get this error "uncaught syntaxerror unexpected token U" when I run my page in chrome. And in firefox I get, "JSON.parse: unexpected character". I'm returning the json data from a php file and the returning json string is valid. I checked it with http://jsonlint.com/ . Any help would be appreciated... Thanks.

这是返回的JSON字符串

Here's the returned JSON string

[
    ["1","Pan Africa Market","\"1521 1st Ave, Seattle, WA\"","47.608941","-122.340145","restaurant"],
    ["2","The Melting Pot","14 Mercer St, Seattle, WA","47.624562","-122.356442","restaurant"],
    ["3","Ipanema Grill","1225 1st Ave, Seattle, WA","47.606366","-122.337656","restaurant"],
    ["4","Sake House","230 1st Ave, Seattle, WA","47.612825","-122.34567","bar"],
    ["5","Crab Pot","1301 Alaskan Way, Seattle, WA","47.605961","-122.34036","restaurant"],
    ["6","Mexican Kitchen","2234 2nd Ave, Seattle,WA","47.613975","-122.345467","bar"],
    ["7","Wingdome","1416 E Olive Way, Seattle, WA","47.617215","-122.326584","bar"],
    ["8","Piroshky Piroshky","1908 Pike pl, Seattle, WA","47.610127","-122.342838","restaurant"]
]

推荐答案

JSON.parse的值实际上是undefined时,通常会看到该错误. 因此,我将检查试图解析此代码的代码-很可能您没有解析此处显示的实际字符串.

That error is normally seen when the value given to JSON.parse is actually undefined. So, I would check the code that is trying to parse this - most likely you are not parsing the actual string shown here.

这篇关于未捕获的语法错误意外令牌U JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆