I have a rest service exposed using spring boot rest controller but with the response i'm sending object's properties those has null values.
For ex : ReponseEntity.ok(list) and that list consist of Objects A with lot of null properties.
Is there an easy way of excluding those null properties with spring boot tools?
You can try this in application.properties file
spring.jackson.default-property-inclusion=non_null
Ref - https://docs.spring.io/spring-boot/docs/2.0.0.M3/reference/html/howto-spring-mvc.html#howto-customize-the-jackson-objectmapper
or you can try following annotation in class level or property level
@JsonInclude(JsonInclude.Include.NON_NULL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With