Skip to content

Instantly share code, notes, and snippets.

@ataube
Created January 3, 2013 14:52
Show Gist options
  • Save ataube/4444010 to your computer and use it in GitHub Desktop.
Save ataube/4444010 to your computer and use it in GitHub Desktop.
Spring 3.2 Custom JSON Serialization with Jackson ObjektMapper with XML Configuration
<mvc:annotation-driven>
<mvc:message-converters>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper" ref="jacksonObjectMapper"></property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean id="jacksonObjectMapper" class="de.taube.modellbau.JsonObjectMapper" />
//imports...
public class JsonObjectMapper extends ObjectMapper {
@Autowired
WebApplicationContext context;
public JsonObjectMapper() {
SimpleModule module = new SimpleModule();
module.addSerializer(MyDomainType.class, new TestSerializer(context));
this.registerModule(module);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment