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”键上有错误。它在哪里?!!?