I have a third party class which uses JsonTypeInfo to serialize the type info into a property named data. In the serialized JSON, i do not want the type info to appear. Sadly, I don't have control over the third party class. Is there a way to ignore this field?
@JsonTypeInfo(
use = Id.NAME,
include = As.PROPERTY,
property = "data"
)
public abstract class Data {
}
class TestData extends Data {
private String name;
//Getters and setters, constructors etc
}
TestData testData = new TestData();
testData.setName("randomName");
ObjectMapper mapper = new ObjectMapper();
String output = mapper.writeValueAsString(testData);
//output = {"data": "TestData", "name": "randomName"}
//I don't want data fieldThanks,
Neha