I'm using jackson-databind version 2.12.3 with java8
Create myObject:
MyObject myObject = new MyObject();
myObject.setField1("value1");
myObject.setField2("value2");
Link link = new Link();
link.setField(new HrefType().href("/link"));
link.put("test",new HrefType().href("/test"));
myObject.setLinks(link);
on serialize myObject should return like this:
{
"field1":"value1",
"field2":"value2",
"links":{
"field":{
"href":"/link"
},
"test":{
"href":"/test"
}
}
}
But with the default ObjectMapper the "myObject.link.field" is ignored and the returned json is:
{
"field1":"value1",
"field2":"value2",
"links":{
"test":{
"href":"/test"
}
}
}
My classes are these:
public class Link extends HashMap<String, HrefType> {
private HrefType field = null; //ERROR: this field is ignored on serializer
...
}
public class HrefType {
private String href = null;
...
}
public class MyObject {
private String field1 = null;
private String field2 = null;
private Link links = null;
...
}
I think it's a bug which ignores the fields of the class that extends a hashmap
I'm using jackson-databind version 2.12.3 with java8
Create myObject:
on serialize myObject should return like this:
{ "field1":"value1", "field2":"value2", "links":{ "field":{ "href":"/link" }, "test":{ "href":"/test" } } }But with the default ObjectMapper the "myObject.link.field" is ignored and the returned json is:
{ "field1":"value1", "field2":"value2", "links":{ "test":{ "href":"/test" } } }My classes are these:
I think it's a bug which ignores the fields of the class that extends a hashmap