You can create a custom ObjectMapper where you set the
serializationInclusion property to NON_NULL. Then pass that to the
constructor for JacksonJsonProvider.

https://stackoverflow.com/questions/31636773/remove-null-value-field-from-apache-cxf-rest-response
On Sun, Oct 7, 2018 at 3:15 AM Kulbhushan Azad <kulbhushan.cu...@gmail.com>
wrote:

> hi ,
>
> i am trying to remove the null values from my json response,However , i am
> not able to get it removed.
> i am using CXF 3.0.6 and jackson:2.9.1.
> How can i troubleshoot this? how do i see which jsonprovider is being used?
> how can i get rid of the null values ?
>
> i have a POJO with below annotation at the class level.
>
> @JsonInclude(JsonInclude.Include.NON_NULL)
>
> and below is the rest service spring configuration
>
>    <jaxrs:server id="testService" address="/test">
>             <jaxrs:serviceBeans>
>                 <ref bean="testBean" />
>             </jaxrs:serviceBeans>
>             <jaxrs:extensionMappings>
>                 <entry key="xml" value="application/xml" />
>                 <entry key="text" value="application/text" />
>                 <entry key="gzip" value="application/gzip" />
>                 <entry key="octet-stream" value="application/octet-stream"
> />
>             </jaxrs:extensionMappings>
>             <jaxrs:providers>
>                 <ref bean="jsonProvider" />
>             </jaxrs:providers>
>             <jaxrs:features>
>                 <cxf:logging />
>             </jaxrs:features>
>     </jaxrs:server>
>
>     <bean id="jsonProvider"
> class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
> --
> Thanks
> Kulbhusan
>

Reply via email to