xxxxxxxxxx
public class Object {
@JsonInclude(NON_NULL)
@JsonProperty("property")
private String property;
}
xxxxxxxxxx
public class MyDto {
@JsonInclude(Include.NON_NULL)
private String stringValue;
private int intValue; // standard getters and setters
}
xxxxxxxxxx
@JsonInclude(Include.NON_NULL)
public String getStudentName() {
return studentName;
}
(or)
@JsonInclude(Include.NON_NULL)
public void setStudentName(String studentName) {
this.studentName = studentName;
}
xxxxxxxxxx
mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);