• 将部分字符串转化成JsonArray


    方法1:

    现将string转化成JSONObject,利用jsonObject的getJsonArray(String key)方法,获取只包含jsonArray的部分Json数组,再利用jsonArray的getJSONObject(int index)方法获取数组的某个JsonObject,再通过JsonObject.parse(string,Object.class)来转换成javaBean

    String res = HttpClientUtil.doPost(checkUrl, param, headers, "utf-8");
    JSONObject jo = JSONObject.parseObject(res);
    JSONArray rows = jo.getJSONArray("rows");

    方法2:

    String res=getCustInfo.getCustListInfoByName(user,custName);
    String res1= JSONObject.parseObject(res).getString("rows");
    JSONArray list=JSONObject.parseArray(res1);
    //Customer customer=JSONObject.parseObject(list.getJSONObject(0).toJSONString(),Customer.class);

    方法1比方法2要简单一些,

    方法1:String-》JsonObject-》jsonArray

    方法2:String-》JsonObject-》String-》JsonArray

  • 相关阅读:
    odoo10 入门
    git 命令详细介绍
    odoo中Python实现小写金额转换为大写金额
    {DARK CTF } OSINT/Eye
    2020 12 18
    2020 12 17
    2020 12 16
    2020 12 15
    2020 11 14
    2020 11 13
  • 原文地址:https://www.cnblogs.com/saifei1125/p/12175746.html
Copyright © 2020-2023  润新知