For Spring Boot 1.2.3, how to set ignore null value in JSON serialization?
For Spring Boot 1.4.x, you can include the following line to your application.properties
spring.jackson.default-property-inclusion=non_null
This was a good solution before deprecation:
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
But now you should use:
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClassName {
...
You can take a look here: https://fasterxml.github.io/jackson-annotations/javadoc/2.7/com/fasterxml/jackson/annotation/JsonInclude.Include.html
Add the following line to your application.properties
file.
spring.jackson.default-property-inclusion=non_null
For versions of Jackson prior to 2.7:
spring.jackson.serialization-inclusion=non_null