Map类型的Json格式


示例代码:

Map<String, Object> map = new HashMap<>();
// boolean 类型 map.put("boolean", true);
// String 类型 map.put("string", "abc");
// int 类型 map.put("int", 123);
// 数组类型 map.put("array", new int[]{1,2,3});
// map 类型 Map<String, Object> subMap = new HashMap<>(); subMap.put("key1", "value1"); subMap.put("key2", "value2"); map.put("map", subMap); System.out.println(JSON.toJSONString(map, true));

结果:

{
    "boolean":true,
    "string":"abc",
    "array":[1,2,3],
    "map":{
        "key1":"value1",
        "key2":"value2"
    },
    "int":123
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM