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:zcalv...@motive.com] 
Sent: Thursday, April 25, 2013 2:18 PM
To: users@camel.apache.org
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&amp;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

Reply via email to