I have this code:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = A.class, name="suppressed")
})
interface I{}
class A implements I {
@JsonTypeId
public String getType(){
return "goodA";
}
}
After serialization of new A() in field of type I I expect to get {type: "goodA"}, but instead I get {type: "suppressed"}.
But if I add any other property to A (like public int getFake() {return 0;}) then serialization works right (and I get {type: "goodA", fake: 0}).
That's because BeanSerializerBuilder.build() exits if no "real" properties present ignoring _typeId:
if (_properties == null || _properties.isEmpty()) {
if (_anyGetter == null && _objectIdWriter == null) {
return null;
...
Found in 2.9.5 but code is not changed up to 2.9.7
I have this code:
After serialization of
new A()in field of typeII expect to get{type: "goodA"}, but instead I get{type: "suppressed"}.But if I add any other property to
A(likepublic int getFake() {return 0;}) then serialization works right (and I get{type: "goodA", fake: 0}).That's because
BeanSerializerBuilder.build()exits if no "real" properties present ignoring_typeId:Found in 2.9.5 but code is not changed up to 2.9.7