简体   繁体   English

在Android中解析JSON响应“无法将org.json.JSONObject类型的响应转换为JSONArray”

[英]Parse JSON response in android “response of type org.json.JSONObject cannot be converted to JSONArray”

I've seen there are quite a few questions around, but I think I am missing a detail that I couldn't find out. 我已经看到周围有很多问题,但是我想我缺少一个我找不到的细节。

The String I am getting as a response is included in the following error: 我作为响应得到的字符串包含在以下错误中:

12-28 10:25:14.402: W/System.err(2133): org.json.JSONException: Value
{"status":"ok","userTier":"developer","total":1722082,"startIndex":1,"pageSize":5,"currentPage":1,"pages":344417,"orderBy":"newest",
"results":[{"webTitle":"AirAsia flight loses contact with air traffic control between Indonesia and Singapore","webPublicationDate":"2014-12-28T09:06:55Z","sectionName":"World news","sectionId":"world","id":"world\/live\/2014\/dec\/28\/airasia-flight-loses-contact-with-air-traffic-control-on-route-from-indonesia-to-singapore","webUrl":"
...  at response of type org.json.JSONObject cannot be converted to JSONArray

My code is 我的代码是

JSONObject jObject = new JSONObject(result);// result is the sting response presented above
JSONArray jArray = jObject.getJSONArray("response");

response键是JSONObject,您需要使用getJSONObject代替当前方法。

The only JSONArray I see is the results key. 我看到的唯一JSONArray是结果键。 You have to use the results key or you need the getJSONObject()-Method, as gio mentioned above. 您必须使用result键,或者需要使用getJSONObject()-Method,如gio所述。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型为org.json.JSONObject的响应无法转换为JSONArray - at response of type org.json.JSONObject cannot be converted to JSONArray org.json.JSONObject无法转换为JSONArray - org.json.JSONObject cannot be converted to JSONArray 无法将org.json.JSONObject类型的数据转换为JSONArray - Data of type org.json.JSONObject cannot be converted to JSONArray at 类型 org.json.JSONObject 的数据无法转换为 JSONArray - at data of type org.json.JSONObject cannot be converted to JSONArray 值类型 org.json.JSONObject 无法转换为 JSONArray - Value type org.json.JSONObject cannot be converted to JSONArray 错误org.json.JSONObject无法转换为JSONArray - error org.json.JSONObject cannot be converted to JSONArray 解析JSON数组时,获取异常“ org.json.JSONObject类型的答案无法转换为JSONArray” - Getting exception “ at answer of type org.json.JSONObject cannot be converted to JSONArray” while parsing JSON array 我有一个错误:类型 org.json.JSONObject 无法转换为 JSONArray - I have an error : type org.json.JSONObject cannot be converted to JSONArray 无法在org.json.JSONArray类型的0值[]转换为android中的JSONObject? - Value [] at 0 of type org.json.JSONArray cannot be converted to JSONObject in android? org.json.JSONException:值 {“storeid0”:[“1535”],“storeid1”:[“1862”]} 类型为 org.json.JSONObject 的 idddsss 无法转换为 JSONArray - org.json.JSONException: Value {“storeid0”:[“1535”],“storeid1”:[“1862”]} at idddsss of type org.json.JSONObject cannot be converted to JSONArray
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM