我正在尝试从 Assets 文件夹中读取 JSON 文件。但是我得到以下异常
org.json.JSONException:字符 550 处的预期文字值
我搜索了很多东西,但没有找到任何相关的东西。这是我的 JSON 文件。
我发现 550 上的 JSON 对象是 "names": ["Santosh","Sandip","Arvind"],
。我正在尝试解决它,但不知道我的代码中会发生什么。
这是我的代码。
我也调试我的代码,但是当控制继续 JSONObject jsonObject = new JSONObject(text);
它抛出异常并进入第一个 catch block 。
请给我任何引用或提示来解决这个问题。
任何帮助表示赞赏。
最佳答案
您的 JSON 无效。
您的 JSON 应该如下所示
{
"resultCount": 3,
"SearchedTerm": "Wada Pav",
"results": [
{
"locationname": "Mahableshwar Hotel",
"locationid": "12345",
"locationaddress": "baner, Pune",
"dishrating": "4",
"dishname": "Wada Pav",
"dishid": "234",
"dishcategory": "Snacks",
"dishnotes": "Spicy Wada Pav",
"dishpreviewurl": "http://xxx.yyy.zzz/mahableshwar/1.jpg",
"dishtotalvotes": "9999",
"friendslistvoted": {
"friendscount": "3",
"names": [
"Santosh",
"Sandip",
"Arvind"
]
},
"dishimageurl": "http://xxx.yyy.zzz/mahableshwar/2.jpg",
"mylastrating": "4"
}
]
}
在使用之前尝试使用 JSON 验证器(如 JSLint )。
关于android - 组织.json.JSONException : Expected literal value at character 550 of,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14009352/