永发信息网

map的json对象是什么样的

答案:1  悬赏:60  手机版
解决时间 2021-04-27 04:23
  • 提问者网友:暮烟疏雨之际
  • 2021-04-27 00:02
map的json对象是什么样的
最佳答案
  • 五星知识达人网友:一袍清酒付
  • 2021-04-27 00:11
Map map = new HashMap<>();
map.put("boolean", true);
map.put("string", "abc");
map.put("int", 123);
map.put("array", new int[]{1,2,3});
Map 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
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯