Android: JSONObject cannot be converted to JSONArray
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to get data from php file to Android using JSON. This is my code: .... HttpEntity e = r.getEntity(); String data = EntityUtils.toString(e); JSONArray timeline = new JSONArray(data); JSONObject last = timeline.getJSONObject(0); return last; When I debug the program there is JSONException on this line: JSONObject last = timeline.getJSONObject(0); Data is {"a":1,"b":2,"c":3,"d":4,"e":5} and the Exception is: org.json.JSONException: Value {"d":4,"e":5,"b":2,"c":3,"a":1} of type org.json.JSONObject cannot be converted to JSONArray 回答1: The