我一直在与我的应用程序中的一些 JSON 解析作斗争,经过 3 天的研究,我仍然无法弄清楚这个问题。
正在发送的错误是“org.json.JSONException: Value”
我一直在处理的 try/catch 语句中出现错误。
我的 Try/Catch 看起来像这样:
Try {
// Result comes in from an HTTP Request
JSONArray jarray = new JSONArray(result);
JSONObject jObj = jarray.getJSONObject(0).getJSONObject("results");
String TeamName = jObj.getString("fulltext");
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
我得到的完整 JSON 位于此处,但精简版如下:
{
"query-continue-offset": 50,
"query": {
"printrequests": [{
"label": "",
"typeid": "_wpg",
"mode": 2,
"format": false
}],
"results": {
"Team:\"Die Unglaublichen\"": {
"printouts": [],
"fulltext": "Team:\"Die Unglaublichen\"",
"fullurl": "http:\/\/wiki.planetkubb.com\/wiki\/Team:%22Die_Unglaublichen%22",
"namespace": 822,
"exists": true
},
"Team:(Can't Stand) Le Kubb Bricks": {
"printouts": [],
"fulltext": "Team:(Can't Stand) Le Kubb Bricks",
"fullurl": "http:\/\/wiki.planetkubb.com\/wiki\/Team:(Can%27t_Stand)_Le_Kubb_Bricks",
"namespace": 822,
"exists": true
},
"Team:(OHC) Kubb Team": {
"printouts": [],
"fulltext": "Team:(OHC) Kubb Team",
"fullurl": "http:\/\/wiki.planetkubb.com\/wiki\/Team:(OHC)_Kubb_Team",
"namespace": 822,
"exists": true
},
"Team:Andrewsons3": {
"printouts": [],
"fulltext": "Team:Andrewsons3",
"fullurl": "http:\/\/wiki.planetkubb.com\/wiki\/Team:Andrewsons3",
"namespace": 822,
"exists": true
}
},
"meta": {
"hash": "46923025c2d5aac3ee963419db93485d",
"count": 50,
"offset": 0
}
}
}
这是我第一次看到 JSON 代码,老实说,一开始有点困惑,但我可以理解 JSON 是如何工作的,只是不知道如何从这些数组中获取数据!
我错过了一些东西,我只是看不到什么......