json include non null code example
Example 1: jackson ignore null
public class MyDto {
@JsonInclude(Include.NON_NULL)
private String stringValue;
private int intValue; // standard getters and setters
}
Example 2: jackson ignore value if null
public class Object {
@JsonInclude(NON_NULL)
@JsonProperty("property")
private String property;
}
Example 3: json null
JSONObject obj = ...
boolean hasProperty = obj.has("propertyName");
boolean isPropertyNull = obj.isNull("propertyName");