I have a Spring Boot application with some endpoint that returns a map of items in JSON.
The map consists of bank account statement items grouped by date. The date is key (formated date string) and list of statement items - is a value:
Map<String, List<StatementItem>
Key sorting is always done by date (NOT ALPHABETICALLY), e.g:
{
"Today": [...],
"Yesterday": [...],
"9 Jun 2021": [...],
"8 Jun 2021": [...],
"7 Jun 2021": [...],
"6 Jun 2021": [...]
....
}
The problem is the Angular application that calls that endpoint is not able to handle the response and process obtained map with the same sorting. Keys are sorted alphabetically in the resulting map instead of original sorting from the backend.
HTTP call example:
this.httpClient.get<Map<string, StatementItem[]>>(`some request URL`);
And how the Angular parses map:
Is there any way to "ask" Angular/TypeScript to parse JSON map as is, as it was obtained from the backend?