I have a web application using Spring MVC (3.0.5)
that outputs JSON
using the HttpMessageConverter
when the application/json
is passed in Accept header. I want to output XML
using XStream
, but instead of the underlying Java object, I want to use the JSON
representation that I've already customized.
My spring configuration looks like
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
<bean class="org.springframework.http.converter.FormHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" />
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
I can add another XStreamMashaller
and get the XML
output from the Java Object, but that's a different representation and I don't want to make the effort in syncing the two representations. I want to use the JSON
representation to be converted to XML
using something like Jettison
. Can somebody guide me to a link or some example code on how this can be achieved?