In my RestController I am returning a POJO which has a LinkedHashMap.
public class ReportTypesVO {
private LinkedHashMap<Integer,EachReportTypeVO> reportTypes;
public LinkedHashMap<Integer, EachReportTypeVO> getReportTypes() {
return this.reportTypes;
}
public void setReportTypes(LinkedHashMap<Integer, EachReportTypeVO> reportTypes) {
this.reportTypes = reportTypes;
}}
My API:
@RequestMapping(value = "/dailyReport", method = RequestMethod.POST)
public ReportTypesVO populateDailyReportScreen() throws Exception {
ReportProcess reportProcessing = new ReportProcess();
logger.info("populateDailyReportScreen Service reached");
ReportTypesVO response=reportProcessing.loadReportTypes(ReportProcess.DAILY_REPORT_METADATAID);
return response;
}
In the "loadReportTypes" method I am populating this LinkedHashMap and this map is getting populated in desired order.then after setting this map inside "reportTypesVo" also i can see the entries inside map is in desired order. But when I see the Response JSON the entries inside map is in a different order. FYI now I am hitting the service with POST MAN.Jre version-7 Where is the issue ? Is Spring having some inbuilt functionality to change order in JSON ?