I am sending a HashMap object as response from my 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());
}
How to control the order of JSON properties when returning a Map object?
CodePudding user response:
LinkedHashMap
maintains insertion order:
Map<String, Object> response = new LinkedHashMap<>();