You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An attempt to change the default abstract type mapper from LinkedHashMap to something else (in this case TreeMap) does not work:
public static void main(String ... args) throws Exception
{
final ObjectMapper mapper = new ObjectMapper();
final SimpleModule module = new SimpleModule("treemaps", Version.unknownVersion());
module.addAbstractTypeMapping(Map.class, TreeMap.class);
mapper.registerModule(module);
final String ser = "{\"obj\":{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":\"v3\"}}";
final Map<String, Object> deser = mapper.readValue(ser, new TypeReference<TreeMap<String, Object>>() {});
System.out.println("Class of deser's nested object is " + deser.get("obj").getClass().getSimpleName());
}
The output of this is Class of deser's nested object is LinkedHashMap.
This is using version 2.5.0.
The text was updated successfully, but these errors were encountered:
An attempt to change the default abstract type mapper from
LinkedHashMap
to something else (in this caseTreeMap
) does not work:The output of this is
Class of deser's nested object is LinkedHashMap
.This is using version 2.5.0.
The text was updated successfully, but these errors were encountered: