zoukankan      html  css  js  c++  java
  • 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());
  • 相关阅读:
    Boliuraque OI 总结
    HNU 1447 最长上升路径
    妹纸
    某个子串的循环节
    跳石头
    小澳的葫芦
    递推式的循环问题
    BZOJ 2326 数学作业
    BZOJ 2337 XOR和路径
    hdu5468 Puzzled Elena
  • 原文地址:https://www.cnblogs.com/jing1617/p/7262468.html
Copyright © 2011-2022 走看看