How to ignore json empty or null values using Jackson API in java?
In this example you will know how to ignore json empty or null values using jackson API. All you need to do is add @JsonInclude
annotation to the class.
how to use @JsonPropertyOrder annotation. If you want to exclude null values, use @JsonInclude annotation with Include.NON_NULL value as
shown below:
Note: Refer How to convert Java object to JSON string? page for dependent libraries.
@JsonInclude(Include.NON_NULL)
|
If you want to exclude empty values, use @JsonInclude annotation with Include.NON_EMPTY value as
shown below:
@JsonInclude(Include.NON_EMPTY)
|
|