Bah, solved it.
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
<property name="dropRootElement" value="true"/>
<property name="supportUnwrapped" value="true" />
</bean>
...
<camel:to uri="cxfbean:jettyConsumerList?providers=jsonProvider"/>
...
-----Original Message-----
From: Calvert, Zach (Zach)** CTR ** [mailto:[email protected]]
Sent: Thursday, April 25, 2013 2:18 PM
To: [email protected]
Subject: Setting Default JSON Provider
I have a route
<camel:route id="messagePath">
<camel:from
uri="jetty:http://0.0.0.0:8080/?matchOnUriPrefix=true&enableMultipartFilter=false"/>
<camel:to uri="cxfbean:consumerList"/> </camel:route>
and a bean configured:
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
<property name="dropRootElement" value="true"/>
<property name="dropCollectionWrapperElement" value="true"/>
<property name="serializeAsArray" value="true"/>
<property name="ignoreNamespaces" value="true"/> </bean>
How can I set this JSON Provider as my default provider for the cxfbean output
of a function with the header like:
@GET
@Path("/sample")
@Produces({"application/json"})
public MyTest getSample() {
I get MyTest output, but it is not using the jsonProvider I want. The format
comes back as {"myTest":{"id":"3e1fd608-130c-46c3-8e13-0bc93182f6d2"}}
when I want the root element removed and just get the
{"id":"3e1fd608-130c-46c3-8e13-0bc93182f6d2"}
as the response body.
Thanks,
Zach Calvert