zoukankan      html  css  js  c++  java
  • json遍历key value

    http://blog.csdn.net/lanshengsheng2012/article/details/17679487

    public static void main(String[] args) {
    String json = "{"table": "viewTable","data": [{"ctime": "2016-08-24 00:00:00","city": "beijing","count1": "1","count2": "2"},"+
    "{"ctime": "2016-08-25 00:00:00","city": "shanghai","count1": "4","count2": "3"}]}";
    JSONObject jsonObject = JSONObject.fromObject(json);
    String tableName = jsonObject.getString("table");
    System.out.println(tableName);
    JSONArray jsonArray = jsonObject.getJSONArray("data");
    for(int i = 0 ;i < jsonArray.size() ; i++){
    JSONObject jsonObj = JSONObject.fromObject(jsonArray.getString(i));
    //http://blog.csdn.net/lanshengsheng2012/article/details/17679487
    Iterator it = jsonObj.keys();
    while(it.hasNext()){
    String key = it.next().toString();
    String value = jsonObj.getString(key);
    System.out.println(key+":"+value);
    }
    }
    }

  • 相关阅读:
    android 设置时间和日期
    android 对话框
    android notification 通知
    android 动画(转载)
    js的作用域题
    js高级
    js中级6
    js中级小知识5
    js中级小知识4
    js中级小知识3
  • 原文地址:https://www.cnblogs.com/sj521/p/6140181.html
Copyright © 2011-2022 走看看