I want to serialize a POJO class which is not under my control, but want to avoid serializing any of the properties which are coming from the superclass, and not from the fi
You can override the superclass' methods which you'd like to prevent from being output and annotate them with @JsonIgnore. The override shifts the control of property creation to the subclass while enabling its ability to filter it from the output.
For instance:
public class SomeClass {
public void setField1(...);
public Integer getField1();
public void setField2(...);
public Integer getField2();
@Override
@JsonIgnore
public String superClassField1(...){
return super.superClassField1();
};
@Override
@JsonIgnore
public String superClassField2(...){
return super.superClassField2();
};
...
}