Map, Object> map = new HashMap , Object>(); Map , List> param = new HashMap , List>(); param.put("class", Arrays.asList(1,2,3,4)); param.put("student", Arrays.asList(1, 2, 3, 4)); map.put("lineChart", param); System.out.println(JSONObject.fromObject(map).toString());打印结果为
{"lineChart":{"student":[1,2,3,4]}}
Map, Object> map = new HashMap, Object>();
Map, List> param = new HashMap, List>();
param.put("grade", Arrays.asList(1,2,3,4));
param.put("student", Arrays.asList(1, 2, 3, 4));
map.put("lineChart", param);
System.out.println(JSONObject.fromObject(map).toString());
打印结果为:
{"lineChart":{"student":[1,2,3,4],"grade":[1,2,3,4]}}
也就是键为class的map再次放入一个map中,该键值对会消失