Hi,

I just did some test, the below route should work

from("direct:json").unmarshal().json(JsonLibrary.Gson)

from("direct:json").unmarshal().json(JsonLibrary.Gson, Map.class)

It looks you need to enable the StreamCache[1] as the input stream is consumed.

[1]http://camel.apache.org/stream-caching.html

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: willemjiang





On Friday, October 26, 2012 at 10:50 PM, clakech wrote:

> Hi,
>  
> Thank you for answering my question:
>  
> @Willem: As I explained I my mail, I know that I can do this with a
> processor or a bean bu I would like to be able to do it with the json
> component.
>  
> @Marco: I already try the json component but I get an error when using:
>  
> unmarshal().json()...
> or
> unmarshal().json(JsonLibrary.Gson, Map.class)..
> etc...
> without succes :'(
>  
> Exhausted after delivery attempt: 1 caught: java.io.EOFException: No
> content to map to Object due to end of input
> java.io.EOFException: No content to map to Object due to end of input
>  
> I am looking for a code sample that would allow me to parse my json into a
> simple map.
>  
> Regards,
>  
> Cyril Lakech
>  
>  
> 2012/10/26 Marco Westermann [via Camel] <
> ml-node+s465427n5721608...@n5.nabble.com 
> (mailto:ml-node+s465427n5721608...@n5.nabble.com)>
>  
> > Hi,
> >  
> > there is a json data type you can use for un/marshalling.
> >  
> > have a look here:
> >  
> > http://camel.apache.org/json.html
> >  
> > regards, Marco
> >  
> > Am 26.10.2012 11:51, schrieb clakech:
> >  
> > > Hi,
> > >  
> > > I would like to unmarshal a Json to a Map/List of Strings (eg
> > Map<String,
> > > Map&lt;String, Maps>>...)
> > >  
> > > Here is my input:
> > > {"pointsOfSale":
> > > {"pointOfSale":[
> > > {"href":"\/pointsOfSale\/UUID.0abc2aca-7930-4c9e-9f38-8af3d0692e04",
> > > "model":{"href":"\/models\/modelePointOfSale",
> > > "modelType":{"href":"\/modelTypes\/pointOfSale"}},
> > > "source":{"href":"\/sources\/TEST"},
> > > "attribute":[
> > > {"code":"pointOfSalePhysical","value":true},
> > > {"code":"mail","value":"Mail1"},
> > > {"code":"adresse","value":"address1"}]},
> > > {"href":"\/pointsOfSale\/UUID.a12e7adf-652a-4197-91bf-d4785e43f09f",
> > > "model":{"href":"\/models\/modelePointOfSale",
> > > "modelType":{"href":"\/modelTypes\/pointOfSale"}},
> > > "source":{"href":"\/sources\/Wikeo"},
> > > "attribute":[
> > > {"code":"pointOfSalePhysical","value":false},
> > > {"code":"mail","value":"Mail1"},
> > > {"code":"adresseMateriau","value":"Material address1"}]}
> > > }}
> > >  
> > > I would like to be able to do "something" like this after unmarshaling:
> > myJsonMapped.get("pointsOfSale").get("pointOfSale").get(0).get("source").get("href").equals("\/sources\/TEST")
> >  
> > > == true
> > >  
> > > For instance, with Gson we can do this kind of decoding:
> > >  
> > > new Gson().fromJson(json, Map.class);
> > >  
> > > I know I can do this with a simple bean or processor etc...
> > >  
> > > I just want to know of I can do this more efficiently with a native JSON
> > > camel component config
> > >  
> > >  
> > >  
> > > --
> > > View this message in context:
> >  
> >  
> > http://camel.465427.n5.nabble.com/unmarshal-JSON-to-Map-List-of-Strings-tp5721600.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com 
> > > (http://Nabble.com).
> >  
> >  
> >  
> >  
> >  
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >  
> > http://camel.465427.n5.nabble.com/unmarshal-JSON-to-Map-List-of-Strings-tp5721600p5721608.html
> > To unsubscribe from unmarshal JSON to Map/List of Strings, click 
> > here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5721600&code=Y3lyaWwubGFrZWNoQGFkZW9zZXJ2aWNlcy5jb218NTcyMTYwMHwxMjE3MDgxODg5>
> > .
> > NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble:email.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble:email.naml-instant_emails%21nabble:email.naml-send_instant_email%21nabble:email.naml>
>  
>  
>  
> --  
> Ce message et toutes les pièces jointes sont établis à l'attention  
> exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce  
> message par erreur, merci de le détruire et d'en avertir immédiatement  
> l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce  
> message, le contenu de ce message ne représente en aucun cas un engagement  
> de la part de GROUPE ADEO.
>  
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/unmarshal-JSON-to-Map-List-of-Strings-tp5721600p5721613.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to