【发布时间】:2017-04-10 10:35:14
【问题描述】:
我有一张像下面这样的地图
Map<String,List<status>> statusmap=new HashMap<String,List<status>>();
因此,当我将此地图输出为 JSON 数据时,我会执行以下操作:
return new ResponseEntity<Map<String,List<status>>>(statusmap,HttpStatus.OK);
提供以下 JSON 数据。
{"status":[{"connection":"OK","message":"Success"}]}
如上所述,我还有另一张地图
Map <String,List<Model>> modelmap= new HashMap<String,List<Model>>();
因此,当我将此地图输出为 JSON 数据时,我会执行以下操作:
return new ResponseEntity<Map <String,List<Model>>>
提供以下 JSON 数据。
{"apidata":[{"id":1,"score":8},{"id":2,"score":6},{"id":3,"score":5}]}.
现在我希望这两个数据在某种意义上被合并
{"status":[{"connection":"OK","message":"Success"}],"apidata":[{"id":1,"score":8},{"id":2,"score":6},{"id":3,"score":5}]}
我试过Map<Map<String,List<status>>,Map <String,List<Model>>> result=new HashMap <Map<String,List<status>>,Map <String,List<Model>>>();
result.put(statusmap,modelmap);
但它并不是想要的格式。 任何帮助表示赞赏。
【问题讨论】: