zoukankan      html  css  js  c++  java
  • fastjson --JSONObject 和JSONArray 转换

    fastjson解析:
    resultValue=
    [
        {
            "total": 1,
            "saleLists": [
                {
                    "categoryInfo": "测试父分类",
                    "id": 12,
                    "vendor_code": 0,
                    "brandInfo": "非龙品牌,",
                }
            ]
        }
    ]
    第一步:解析完成以后 {"total": 1,"saleLists": [{"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}]}
         JSONObject js=JSON.parseObject(JSON.parseArray(resultValue).get(0).toString());

    第二步:解析完成后   [{"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}]

         JSONArray js2=JSON.parseArray(js.getString("saleLists").toString());

    第三步:解析完成后  {"categoryInfo": "测试父分类","id": 12,"vendor_code": 0,"brandInfo": "非龙品牌,",}

         JSONObject jsObj2=JSON.parseObject(js2.get(0).toString());

    第四步:js2jsObj2.getString("id"),得到12

     
  • 相关阅读:
    排序简介
    排序集锦
    排序图解
    UVA 11809
    uva1588kickdown
    C++中输入输出的重定向
    uva1587BOX
    uva 10340 All in All
    uva 1368 DNA Consensus String
    彻底理解MapReduce shuffle过程原理
  • 原文地址:https://www.cnblogs.com/paisen/p/5487138.html
Copyright © 2011-2022 走看看