At the deserialization process (which as I understand is the process of converting JSON data into a Java Object), how can I tell Jackson that when it reads a object that con
Approach 1 : This is mostly used. @JsonInclude is used to exclude properties with empty/null/default values.Use @JsonInclude(JsonInclude.Include.NON_NULL) or @JsonInclude(JsonInclude.Include.NON_EMPTY) as per your requirement.
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Employee {
private String empId;
private String firstName;
@JsonInclude(JsonInclude.Include.NON_NULL)
private String lastName;
private String address;
private String emailId;
}
More info about the jackson annotations : https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations
Approach 2 : GSON
use GSON (https://code.google.com/p/google-gson/)