2016-06-04 3 views
0

JSON 배열이 있는데이 배열에서 데이터를 선택하고 싶습니다. 모든 과목을 듣고 싶지만 어떻게해야할지 모르겠다.JSON 배열에서 JSON 배열 가져 오기 Java android

번호 :

사실
JSONObject jsonObject = new JSONObject(thatarray); 
JSONArray jsonArray = jsonObject.getJSONArray("response"); 
int arrSize = jsonArray.length(); 
List<Integer> sub = new ArrayList<Integer>(arrSize); 

for (int i = 0; i < arrSize; ++i) { 
    jsonObject = jsonArray.getJSONObject(i); 
    System.out.println("Output: " + jsonObject.toString()); 
} 
+2

전체 제목 목록을 가져 오시겠습니까 ?? – ManishMenaria

답변

1

"응답"이 된 JSONObject 및 "데이터"인 u는 {보고} 및 [] ... 가 도움이 희망하여 jsonArray 및 된 JSONObject 구분할 수 .. jsonArray 인 :)

아래 JSON에서 코드를 시도해보고 작동 중입니다.

try { 
     JSONObject jsonObject = new JSONObject(thatarray); 
     jsonObject = jsonObject.getJSONObject("response"); 
     JSONArray jsonArray = jsonObject.getJSONArray("data"); 

     JSONArray jsonArraysubject; 
     for (int i = 0; i < jsonArray.length() - 1; i++) { 
      jsonObject = jsonArray.getJSONObject(i); 
      jsonArraysubject = jsonObject.getJSONArray("subjects"); 

      Log.d("MyLog", jsonArraysubject + ""); 
     } 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 
관련 문제