Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在android中解析JSON响应;类型为org.json.JSONObject的响应无法转换为JSONArray;_Java_Android_Json - Fatal编程技术网

Java 在android中解析JSON响应;类型为org.json.JSONObject的响应无法转换为JSONArray;

Java 在android中解析JSON响应;类型为org.json.JSONObject的响应无法转换为JSONArray;,java,android,json,Java,Android,Json,我看到有很多问题,但我想我遗漏了一个我无法发现的细节 作为响应获取的字符串包含在以下错误中: 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",

我看到有很多问题,但我想我遗漏了一个我无法发现的细节

作为响应获取的字符串包含在以下错误中:

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
而不是当前方法。

我看到的唯一JSONArray是results键。您必须使用results键,或者需要getJSONObject()-方法,正如gio上面提到的。

我找不到response键您在“response”键上有错误。它在哪里?!!?