Configuration for REST spring mvc with Jackson json mapper omitting null properties

Putting this configuration into my spring res-mvc-config.xml changed the json responses so that null properties are not written. To make this changes have an effect you have to get rid of any mvc:annotation-driven element as this stops the overriding having an effect. no errors will be thrown, so it’s not easy to see what is going on or not going on 😉

<<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”;

<context:component-scan base-package=””></context:component-scan>

<context:component-scan base-package=””></context:component-scan>
<!– <mvc:annotation-driven/> –>

<property name=”messageConverters”>
<bean> </bean>
<property name=”objectMapper” ref=”jacksonObjectMapper” />

<!– jackson configuration : –>
<bean id=”jacksonObjectMapper” />
<bean id=”jacksonSerializationConfig”
factory-bean=”jacksonObjectMapper” factory-method=”getSerializationConfig” />
<property name=”targetMethod” value=”setSerializationInclusion” />
<property name=”targetObject” ref=”jacksonSerializationConfig” />
<property name=”arguments”>
<value type=””>NON_NULL</value>


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: