Android解析多层嵌套解析

举个栗子:

"provinceData":Array[31],
    "captchaFlag":false,
    "proGroupNum":Object{...},
    "goodsId":"1610241535",
    "resultCode":"0000",
    "cityData":Object{...},
    "resultMsg":"成功"
解析
provinceData
里的试一下,

"provinceData":[
        {
            "PROVINCE_NAME":"北京",
            "PROVINCE_CODE":"11",
            "PRO_ORDER_NUMBER":1
        }
,
        {
            "PROVINCE_NAME":"上海",
            "PROVINCE_CODE":"31",
            "PRO_ORDER_NUMBER":2
        }
,]

代码如下:

	JSONObject jsonObject1=new JSONObject(json);
            JSONArray jsonArray=jsonObject1.getJSONArray("provinceData");
            for (int i=0;i<jsonArray.length();i++){
                JSONObject jsonObject=jsonArray.getJSONObject(i);
                String PROVINCE_NAME=jsonObject.getString("PROVINCE_NAME");
                Log.d(TAG,PROVINCE_NAME);}
输出结果:
MainActivity: 北京
MainActivity: 上海









没有更多推荐了,返回首页