zoukankan      html  css  js  c++  java
  • JSONObject用法

    JSONObject

    取字符串getString

    转JSONObject 对:JSON.parseObject

    JSONObject jsonObjectTemplate = yunzhijiaUtils.getTemplateByCodeId(param5);
    String data = jsonObjectTemplate.getString("data");
    JSONObject dataObj =JSON.parseObject(data);
    String basicInfo =dataObj.getString("basicInfo");
    JSONObject basicInfoObj =JSON.parseObject(basicInfo);
    String formDefId = basicInfoObj.getString("formDefId");

    JSONObject jsonObject = JSON.parseObject(res);
            String data = jsonObject.getString("data");
            JSONObject jsonObjects = JSON.parseObject(data);
            JSONArray ja = jsonObjects.getJSONArray("rows");
            for (int i = 0; i < ja.size(); i++) {
                JSONObject jo = ja.getJSONObject(i);
                String op_way = jo.getString("op_way");
                String op_time = jo.getString("op_time");
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                long lt = new Long(op_time);
                Date date = new Date(lt);
                res = simpleDateFormat.format(date);
                String pwd_no = jo.getString("pwd_no");
                String user_mobile = jo.getString("user_mobile");
                System.out.println(op_way + res + pwd_no + user_mobile + "------------");
            }
    ————————————————
    版权声明:本文为CSDN博主「修仙ing~」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/kxj19980524/article/details/83718971

     JSONArray widgetValue = JSONArray.fromObject(widgetValueStr);

    <!--json数组,字符串转换-->
    <dependency>
        <groupId>net.sf.json-lib</groupId>
        <artifactId>json-lib</artifactId>
        <version>2.4</version>
        <classifier>jdk15</classifier>
    </dependency>
    

    import net.sf.json.JSONArray;

    import net.sf.json.JSONObject;

    使用:

    JSONArray array = JSONArray.fromObject("JSON数组字符串");

    JSONObject jsonObject = JSONObject.fromObject("JSON格式字符串");

    如:

    {
            "type":2,
            "name":"222",
            "content":{
                "title":"222",
                "list":[
                    {"title":"222","content":"222"},
                    {"title":"222","content":"22222 33333 44444"}
                ]}
     }

  • 相关阅读:
    mysql 5.6
    mysql5.7 二进制包安装
    centos 6 编译安装httpd-2.4
    mysql 5.5源码包安装
    BZOJ4945 & 洛谷3825 & UOJ317:[NOI2017]游戏——题解
    BZOJ4943 & 洛谷3823 & UOJ315:[NOI2017]蚯蚓排队——题解
    BZOJ3435 & 洛谷3920 & UOJ55:[WC2014]紫荆花之恋
    BZOJ5343 & 洛谷4602 & LOJ2555:[CTSC2018]混合果汁——题解
    真·APIO2018滚粗记
    BZOJ4518:[SDOI2016]征途——题解
  • 原文地址:https://www.cnblogs.com/gzhbk/p/12651602.html
Copyright © 2011-2022 走看看