I have a JSON file whose content is map of structure Map<LocalDate, Map<String, List<FlexiServer>>>
, and when I try to read this JSON file using object mapper into a map, it does not produce the map as expected.
Function to read JSON file
private Map<LocalDate, Map<String, List<FlexiServer>>> loadOnDailyBasis(String path)
throws IOException {
InputStream stream = this.getClass().getResourceAsStream(path);
return JSON_MAPPER.readValue(stream, Map.class);
}
Calling the function and loading it into a map called data
Map<LocalDate, Map<String, List<FlexiServer>>> data = loadOnDailyBasis(
"/testdata/servers/dailyservers.json");
The data is a LinkedHashMap which has key as date and value is LinkedHashMap. The value which is the internal map has the key as string and value as ArrayList. Till here this is fine, but when I see the contents of this ArrayList, it is again a linked hash map, where the key is the name of the field and value is its value. This is wrong.
Kindly suggest how can I deserialize it properly.