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