美文网首页
JSON数据解析

JSON数据解析

作者: NullUser | 来源:发表于2017-09-04 20:41 被阅读0次

使用官方提供的JSONObject

以以下JSON数据为例
[
{"id":"0","name":"aa"},
{"id":"1","name":"bb"},
{"id":"2","name":"cc"}
]

private void paseJson(String jsondata)
{
    try{
        JSONArray jsonArray = new JSONArray(jsondata);
        for(int i = 0;i < jsonArray.length();i++)
        {
            JSONObject jsonObject = (JSONObject) jsonArray.get(i);
            String id=jsonobject.getString("id");
            String name=jsonObject.getString("name");   
        }
    }catch (Exception e)
       {
          e.printStackTrace();}
       }
}

相关文章

网友评论

      本文标题:JSON数据解析

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