zoukankan      html  css  js  c++  java
  • 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);
        }
       }

  • 相关阅读:
    建立适当的索引
    Windows 10Bash命令
    代码生成工具介绍和使用
    分布式的任务调度框架
    Net分布式系统
    Keepalived+LVS+Nginx负载均衡之高可用
    call,apply,bind
    2015搜狐在线笔试题(内存泄露问题)(转)
    十步完全理解SQL(转)
    Linux shell用法和技巧(转)
  • 原文地址:https://www.cnblogs.com/lyz459/p/3683895.html
Copyright © 2011-2022 走看看