I'm using Jackson Databind 2.7.2 and I have the following annotations on an interface:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = SubType1.class, name = "SubType1"),
@JsonSubTypes.Type(value = SubType2.class, name = "SubType2")})
public interface Common {
String getType();
}
getType is overridden (implemented) in SubType1 and SubType2. The problem is that when an instance of SubType1 or SubType2 is mapped to JSON it contain two fields called type with the same value:
{
"type" : "SubType1",
... // Other properties
"type" : "SubType1"
}
How can I prevent jackson from rendering duplicate fields?