camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Jackson/JSON unmarshall
Date Thu, 11 Jul 2013 06:31:19 GMT
Hi

No this is currently not support by data formats. Though we have a
JIRA ticket to allow bridging data formats from a component, in a
future release.

Then you can use recipient list, eg something a like
<recipientList>
  <simple>dataformat:json:unmarshal?unmarshalType=${bean:foo?method=getPOJOClass</simple>
</recipientList>

Currently you can use a java processor / bean and then use java code
to create the json data format, and invoke its unmarshal operation
from there.


On Mon, Jun 24, 2013 at 11:59 PM, Mike Oxford <moxford@gmail.com> wrote:
> Hi all.
>
> Given that you can use Jackson to unmarshall to "unmarshalTypeName="
> (which works for a 1:1 mapping) how does one go about "dynamically
> unmarshalling" a JSON document to "N-possible classes?"
> eg, full protocol work, based on a piece of the JSON itself.
>
> I can build something using the java DSL, or letting Jackson unmarshal
> to a Map and then building POJOs by hand, but I'm wondering if there's
> a better way, ideally, using the Spring XML syntax.
>
> Something like ..
>
>         <route id="incomingJSON">
>             <from ref="jsonListener" />
>             <unmarshal ref="jsonDF"
> unmarshalTypeRef="com.mypackage.ProtocolHandler"
> method="getPOJOClass"/>
>             <to ref="seda:routeMessage" />
>         </route>
>
> This way I can use a bean to determine which class to map the JSON to,
> instead of hardcoding to a single class.
>
> Thanks,
>
> -mox



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message