如何在android中解析嵌套的Json数组

时间:2016-04-18 08:11:51

标签: android json parsing

{   "错误":null,   " InternalError":null,   " IsSuccessful":是的,   "消息":null,   "分支":[     {       " Id":1,       "姓名":" XYZ",       "年":[         {           " Id":6,           "年":" 2015 - 2016"         }       ]     }   ] }

1 个答案:

答案 0 :(得分:0)

JSONObject mainObj = new JSONOBject("Your Response");
if(mainObj != null){
JSONArray list = mainObj.getJSONArray("Branches");
if(list != null){
    for(int i = 0; i < list.length();i++){
        JSONObject elem = list.getJSONObject(i);
        if(elem != null){
            JSONArray prods = elem.getJSONArray("Years");
            if(prods != null){

                  //Your Code here
                }
            }
        }
    }
 }
相关问题