美文网首页
解析多级json字符串(有数组,有对象)

解析多级json字符串(有数组,有对象)

作者: 极夜w | 来源:发表于2020-05-13 17:49 被阅读0次
public void getData(String data){
        JSONArray jsonArray = JSONArray.fromObject(data);
        if(jsonArray.size()>0){         
            for(int i=0;i<jsonArray.size();i++){
                JSONObject str = JSONObject.fromObject(jsonArray.get(i));
                if(str.has("children")){                    
                    data=str.getString("children");
                    getData(data);                  
                }else{
                    long id=str.getLong("id");
                    String title=str.getString("title");
                }
            }
        }
    }

相关文章

网友评论

      本文标题:解析多级json字符串(有数组,有对象)

      本文链接:https://www.haomeiwen.com/subject/aflonhtx.html