• json对象转换


    String modules =...; //json格式的String对象
    //String对象转换为JSON格式数组
    JSONArray moduleArr=JSONObject.parseArray(modules);
    for(int i=0;i<moduleArr.size();i++){
    //获取数组中一个json对象
    JSONObject moduleObj=moduleArr.getJSONObject(i);
    //获取json对象的一个属性
    String attrConditions=moduleObj.getString("attrConditions")
    //如果属性又是一个json数组,则获取后循环处理
    JSONArray specific=moduleObj.getJSONArray("specific");
    JSONObject inputJson = new JSONObject();
    //json对象转换为json格式的String对象
    inputJson.toString();
    //string转换为json对象
    JSONObject json = JSONObject.parseObject(inputJson);

    //map -- jsonString 

    JSONObject json = new JSONObject(); 

     Map<String, Object> map = new HashMap<String, Object>();
                map.put("12", "string");
                map.put("13", "test");
                System.out.println(JSONObject.fromObject(map).toString());
  • 相关阅读:
    DOM getElementById
    百度之星2014
    游艇租借
    2014年acm亚洲区域赛·鞍山站
    UVALive 4255 Guess
    UVA 10054 The Necklace
    UVA 10047 The Monocycle
    UVA 11624 Fire!
    第九届黑龙江省赛
    剑指offer系列31-----二叉树的下一个节点
  • 原文地址:https://www.cnblogs.com/jing1617/p/7262468.html
Copyright © 2020-2023  润新知