JSON을 사용하여 PHP 파일에서 Android로 데이터를 가져오고 싶습니다. 내가 프로그램을 디버깅 할 때Android : JSONObject를 JSONArray로 변환 할 수 없습니다.
....
HttpEntity e = r.getEntity();
String data = EntityUtils.toString(e);
JSONArray timeline = new JSONArray(data);
JSONObject last = timeline.getJSONObject(0);
return last;
이 줄에 JSONException이있다 :
JSONObject last = timeline.getJSONObject(0);
데이터 {"a":1,"b":2,"c":3,"d":4,"e":5}
하고 예외는 다음과 같습니다 JSON 배열에서
org.json.JSONException: Value {"d":4,"e":5,"b":2,"c":3,"a":1} of type org.json.JSONObject cannot be converted to JSONArray
JSON 개체'{ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5}'입니다. 이 '[{{a ": 1,"b ": 2,"c ": 3,"d ": 4,"e ": 5}]'는 JSONObject가 1 인 JSONArray입니다. – SERPRO