I have a POJO that has an inner map. I want this to deserialize into a HashMap from my JSON, but Jackson deserializes the inner map from the JSON into a LinkedHashMap. I can force it to use HashMap by changing the type of the Map from "Map" to "HashMap", but I want to know if there is a way to tell Jackson to deserialize into a specific implementation of Map?
Here is the JSON:
{
"transforms": {
"variable_name1": [{
"min": 100,
"max": 200,
"value": 0.6
}],
"variable_name2": [{
"min": 100,
"max": 200,
"value": 0.6
}],
"variable_name3": [{
"min": 100,
"max": 200,
"value": 0.6
}]
}
}
And the Transforms class:
public class Transformer {
Map<String, List<Transform>> transforms;
public Transformer() {
transforms = new HashMap<String, List<Transform>>();
}
public void setTransforms(Map<String, List<Transform>> transforms) {
this.transforms = transforms;
}
}
How I am using the ObjectMapper:
try(Reader reader = new InputStreamReader(TransformTester.class.getResourceAsStream("transforms.json"), "UTF-8")) {
ObjectMapper objMapper = new ObjectMapper();
Transformer tr = objMapper.readValue(reader, Transformer.class);
}