Created
January 3, 2013 14:52
-
-
Save ataube/4444010 to your computer and use it in GitHub Desktop.
Spring 3.2 Custom JSON Serialization with Jackson ObjektMapper with XML Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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