camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Costantini <cristiano.costant...@gmail.com>
Subject Re: Message Transformation for JSON
Date Mon, 09 Dec 2013 08:46:22 GMT
Probably it is not an optimal approach in terms of performances (how many
transformations per second do you expect to perform?), but you can use
xmljson (http://camel.apache.org/xmljson.html) data format to Unmarshal
json to xml and use XSLT to transform, then Marshal back to Json.

Check the following route to see if it helps:

<route>
<from uri="jetty:http://0.0.0.0:9999/myJsonEndpoint" />
<convertBodyTo type="java.lang.String" />
<unmarshal>
<xmljson elementName="item" arrayName="list" rootName="root" />
</unmarshal>
<!--
Give it a dump to a file to check the resulting xml and elaborate the
proper xsl
    <to
uri="file:target/incoming?fileName=msg-${date:now:yyyyMMdd_HHmmss_SSS}.xml"/>
-->
<to uri="xslt:my_trasnformation.xsl" />
<marshal>
<xmljson />
<!-- check for otions, I've only used it for unmarshalling -->
</marshal>
<to
uri="file:target/incoming?fileName=msg-${date:now:yyyyMMdd_HHmmss_SSS}.js"/>
</route>




2013/12/9 madusanka <madusankabalasooriya@gmail.com>

> Hi,
>
> source and target data formats are also JSON
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Message-Transformation-for-JSON-tp5744433p5744490.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message