Json解析

{
"INFO":"",
"LIST":{
  "1":{
  "CREATETIME":"2014-04-23 15:52:27:854",
  "ISFILE":0,
  "MODIFYTIME":"2014-04-23 15:52:27:854",
  "NAME":"/我",
  "SIZE":0
  }
 },
"NUM":1,
"RESULT":0
}

JSONObject ja=jo.getJSONObject("LIST");
int number=jo.getInt("NUM");
Log.e("DDDDDDDDDDDD","number:"+number);
for(int i=1;i<=number;i++){
JSONObject jb=ja.getJSONObject(String.valueOf(i));
Log.e("DDDDDDDDDD","creatTime:"+jb.getString("CREATETIME"));
}

 

 {"INFO":"",

"LIST":[{"CREATETIME":"2014-04-23 15:52:27:854","ISFILE":0,"MODIFYTIME":"2014-04-23 15:52:27:854","NAME":"我","SIZE":0}],

"NUM":1,

"RESULT":0

}

 JSONObject jsonObj = new JSONObject(jsonString);
   if(jsonObj.getInt("RESULT")==-1){
    setResult(jsonObj.getInt("RESULT"));
    setInfo(jsonObj.getString("INFO"));
   }else{
    setResult(jsonObj.getInt("RESULT"));
    setInfo(jsonObj.getString("INFO"));
    setNum(jsonObj.getInt("NUM"));
    JSONArray ja=jsonObj.getJSONArray("LIST");
    for(int i=0;i<ja.length();i++){
     JSONObject jb = (JSONObject)ja.opt(i);
    
     FileListInfo info = new FileListInfo();
     info.setName(jb.getString("NAME"));
     info.setIsFile(jb.getInt("ISFILE"));
     info.setSize(jb.getString("SIZE"));
     info.setCreatetime(jb.getString("CREATETIME"));
     info.setModifytime(jb.getString("MODIFYTIME"));
     listinfo.add(info);
    }
   }

 

 

posted @ 2014-04-23 20:56  罗小姿  阅读(153)  评论(0编辑  收藏  举报