I'd like to use Jackson to deserialize JSON strings from client requests to Java objects and use FlexJson to serialize Java objects to response.
In the nutshell the issue is: how to setup the Spring to use Jackson ONLY for request handling and not for response?
In servlet-context.xml I have:
<beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<beans:property name="messageConverters">
<beans:list>
<beans:ref bean="jsonMessageConverter"/>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
</beans:bean>
And in the controller:
@RequestMapping(value = "settings")
public @ResponseBody String getSomeData(@RequestBody UserData userData) {
// userData is automatically deserialized by Jackson
MyView viewForClient = new MyView(userData);
return new JSONSerializer().include(MyView.SERILIZABLE_FIELDS).exclude("*", "*.class").serialize(viewForClient); // here I don't want Jackson to handle the response
}
But this way Jackson also converts to JSON the response already converted by FlexJSON that I don't want.
Is there any solution? Thanks.