You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2013/07/11 08:31:19 UTC

Re: Jackson/JSON unmarshall

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 <mo...@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