Disregard my remark about using Spring to configure - I should have
read further down
on that page I referenced. You can do this:
<dataFormats>
<xmljson id="xmljsonWithOptions" forceTopLevelObject="true"
trimSpaces="true"
removeNamespacePrefixes="true" expandableProperties="d e"/>
</dataFormats>
On Fri, May 3, 2013 at 2:55 PM, Chris Wolf <[email protected]> wrote:
> I an answer the first part:
>
> xmlJsonFormat.setForceTopLevelObject(true);
>
> See:
>
> http://camel.apache.org/xmljson.html
>
> You might need to instantiate the XmlJsonDataFormat using Spring bean rather
> then Camel <dataFormats><json/>
>
> Currently I'm using Java-DSL, but I think it would look like:
>
> <bean id="jack" class="org.apache.camel.model.dataformat.XmlJsonDataFormat">
> <property name="setForceTopLevelObject" value="true"/>
> </bean>
>
> or, if you include the 'p' namespace:
>
> xmlns:p="http://www.springframework.org/schema/p"
>
>
> <bean id="jack" class="org.apache.camel.model.dataformat.XmlJsonDataFormat"
> p:setForceTopLevelObject="true"/>
>
>
> On Fri, May 3, 2013 at 9:03 AM, sarfaraj <[email protected]> wrote:
>>
>> I have camel route which exposes web service. I want to accept a data from
>> web client and convert to JSON object.
>> Curently i am using SOAP UI to send input to above web service.
>>
>> # Here is my input.......
>> <soapenv:Body>
>> <aaa:myData>
>> <arg0>
>> <id>1</id>
>> <name>abc</name>
>> </arg0>
>> </aaa:myData>
>> </soapenv:Body>
>>
>> # My camel route is
>>
>> <dataFormats>
>> <json id="jack" library="Jackson" />
>> </dataFormats>
>>
>> <route id="tcaRoute">
>> <from uri="cxf:bean:soapEndpoint" />
>> <marshal ref="jack" />
>> <to uri="file:src/main/resources/out.txt" />
>> </route>
>>
>> After running this, I get following Output i.e JSON data
>> [{"id":1,"name":"abc"}]
>>
>> So instead of [{"id":1,"name":"abc"}] , I need
>> {"*myData*":{"id":1,"name":"abc"}} because id and name are member of
>> myData
>> class.
>> Here it only return class member not the class.
>> Addition to above i also want to remove "[]" from JSON output.
>>
>> *Could some one tell me what changes i need to do on JSON data format to
>> achive this?*
>>
>> /Note: i referred http://camel.apache.org/json.html/
>>
>> /Sarfaraj
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Issue-in-JSON-marshalling-tp5731970.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.