I am facing a very weird issue(at least that's what I think). I have an API which returns an object in JSON format. There is a linkedHashMap field in this object. This map is showing some weird behaviour. When I am logging this object just before sending it to the client it has data in the format I want. But on the client side the map has the keys in different order compare to the logged one. Below is code :
@GET
@Produces(MediaType.APPLICATION_JSON)
public BookingHistoryResponse getBookingHistory(
@QueryParam("from") int fromId,
){
BookingHistoryRequest request = new BookingHistoryRequest(fromId);
BookingHistoryResponse response = new BookingHistoryResponse();
bookingHistoryService.execute(request, response);
logger.info("before returning the repsonse..");
logger.info(response);
Iterator it = response.getSeatDetailsMap().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
logger.info(pair.getKey() + " = " + pair.getValue());
}
return response;
}
The response of the above code is in correct format. But the response at the client side is totally different than what is getting logged. Since there is no further manipulation done on this object, hence I am not able to find out why the map is giving me different result compare to the logged result. Any insight would be highly appreciated. Thanks in advance.