我正在发送一个HashMap对象作为我的RestController的响应。
@GetMapping("/balance")
public Map<String, Object> fetchAccountsByBalance(){
Map<String, Object> response = new HashMap<>();
response.put("records", totalNumberOfRecords);
response.put("pages", totalPages);
response.put("data", pageResponse.getContent());
}
如何控制JSON属性的顺序时返回一个地图对象?
LinkedHashMap
保持插入顺序:
Map<String, Object> response = new LinkedHashMap<>();