Spring REST Service: how to configure to remove null objects in json response

前端 未结 10 1265
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 07:06

I have a spring webservice that returns a json response. I\'m using the example given here to create the service: http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-exam

10条回答
  •  孤街浪徒
    2020-11-28 07:54

    Since Jackson is being used, you have to configure that as a Jackson property. In the case of Spring Boot REST services, you have to configure it in application.properties or application.yml:

    spring.jackson.default-property-inclusion = NON_NULL
    

    source

提交回复
热议问题