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

Potney Switters

我已经看到周围有很多问题,但是我想我缺少一个我找不到的细节。

我作为响应得到的字符串包含在以下错误中:

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

我的代码是

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

org.json.JSONObject 类型的响应无法转换为 JSONArray

Android JSON解析“无法将org.json.JSONObject类型的数据转换为JSONArray”错误

无法将 JSON 解析的响应转换为数组

类型 org.json.JSONObject 无法转换为 JSONArray Android

将JSON响应转换为地图

将 JSON 响应转换为 gridview

将JSON响应转换为DataTable

将API响应转换为json

将 json 响应转换为表

org.json.JSONObject 类型无法转换为 JSONArray

类型org.json.JSONArray的值无法转换为JSONObject

错误:类型 org.json.JSONArray 无法转换为 JSONObject

解析 JSON - JSONObject 类型的 null 无法转换为 JSONArray

android json解析错误-无法将JSONArray转换为JSONObject

org.json.JSONException:无法将 org.json.JSONArray 类型的 0 值转换为 JSONObject

org.json.JSONException:无法将 org.json.JSONArray 类型的值 [{}] 转换为 JSONObject

JSON解析错误:类型org.json.JSONArray无法转换为JSONObject

org.json.JSONException中的错误:org.json.JSONArray类型无法转换为JSONObject

Ajax JSON响应转换为HighCharts

Android Studio:类型 org.json.JSONArray 无法转换为 JSONObject

org.json.JSONException:org.json.JSONArray类型的值[....]无法转换为JSONObject

将SOAP响应转换为JSONArray

android org.json.JSONArray无法转换为JSONObject吗?

使用 jq 将 JSON 响应转换为键值对

Java将json rest api响应转换为图像

将Google Vision API响应转换为JSON

将响应转换为JSON / String并写入文件

将JSON响应转换为Graph.EducationAssignment对象

将JSON响应转换为(Bootstrap)表