You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ryan Moquin <fr...@gmail.com> on 2015/04/27 01:05:26 UTC

camel-jackson unmarshalling question

Hi, I had a question about unmarshalling a json object to a generic class
type, such as something like, MyClass<Person>.  Due to erasure, Jackson
provides a special way of unmarshalling this type object so that you don't
lose the generic type information, like this:

MyClass<Person> myClass = mapper.readValue(json, new
TypeReference<MyClass<Person>>() {});

Is there anyway to do this with the camel dataformat dsl?  Or does the
unmarshalling have to be done manually someway?

Thanks for help in advance!

Ryan

Re: camel-jackson unmarshalling question

Posted by Ryan Moquin <fr...@gmail.com>.
Thanks for your response Claus!  I think it would be a useful feature..
Maybe I'll try to figure it out one of these days so I can contribute it.

Ryan

On Wed, Apr 29, 2015, 6:15 AM Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> No this is not supported today.
>
> Though we could maybe add that, so you can configure this on the data
> format.
>
> On Mon, Apr 27, 2015 at 1:05 AM, Ryan Moquin <fr...@gmail.com>
> wrote:
> > Hi, I had a question about unmarshalling a json object to a generic class
> > type, such as something like, MyClass<Person>.  Due to erasure, Jackson
> > provides a special way of unmarshalling this type object so that you
> don't
> > lose the generic type information, like this:
> >
> > MyClass<Person> myClass = mapper.readValue(json, new
> > TypeReference<MyClass<Person>>() {});
> >
> > Is there anyway to do this with the camel dataformat dsl?  Or does the
> > unmarshalling have to be done manually someway?
> >
> > Thanks for help in advance!
> >
> > Ryan
>
>
>
> --
> 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
> hawtio: http://hawt.io/
> fabric8 <http://hawt.io/fabric8>: http://fabric8.io/
>

Re: camel-jackson unmarshalling question

Posted by Ryan Moquin <fr...@gmail.com>.
Good point, I forgot I could probably utilize tannotations to do it for
now.  :)

Ryan

On Wed, Apr 29, 2015, 6:28 AM David Karlsen <da...@gmail.com> wrote:

> It can probably be done by adding jackson annotations:
> http://wiki.fasterxml.com/JacksonAnnotations "Polymorphic ...:"
>
>
> 2015-04-29 7:54 GMT+02:00 Claus Ibsen <cl...@gmail.com>:
>
> > Hi
> >
> > No this is not supported today.
> >
> > Though we could maybe add that, so you can configure this on the data
> > format.
> >
> > On Mon, Apr 27, 2015 at 1:05 AM, Ryan Moquin <fr...@gmail.com>
> > wrote:
> > > Hi, I had a question about unmarshalling a json object to a generic
> class
> > > type, such as something like, MyClass<Person>.  Due to erasure, Jackson
> > > provides a special way of unmarshalling this type object so that you
> > don't
> > > lose the generic type information, like this:
> > >
> > > MyClass<Person> myClass = mapper.readValue(json, new
> > > TypeReference<MyClass<Person>>() {});
> > >
> > > Is there anyway to do this with the camel dataformat dsl?  Or does the
> > > unmarshalling have to be done manually someway?
> > >
> > > Thanks for help in advance!
> > >
> > > Ryan
> >
> >
> >
> > --
> > 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
> > hawtio: http://hawt.io/
> > fabric8: http://fabric8.io/
> >
>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>

Re: camel-jackson unmarshalling question

Posted by David Karlsen <da...@gmail.com>.
It can probably be done by adding jackson annotations:
http://wiki.fasterxml.com/JacksonAnnotations "Polymorphic ...:"


2015-04-29 7:54 GMT+02:00 Claus Ibsen <cl...@gmail.com>:

> Hi
>
> No this is not supported today.
>
> Though we could maybe add that, so you can configure this on the data
> format.
>
> On Mon, Apr 27, 2015 at 1:05 AM, Ryan Moquin <fr...@gmail.com>
> wrote:
> > Hi, I had a question about unmarshalling a json object to a generic class
> > type, such as something like, MyClass<Person>.  Due to erasure, Jackson
> > provides a special way of unmarshalling this type object so that you
> don't
> > lose the generic type information, like this:
> >
> > MyClass<Person> myClass = mapper.readValue(json, new
> > TypeReference<MyClass<Person>>() {});
> >
> > Is there anyway to do this with the camel dataformat dsl?  Or does the
> > unmarshalling have to be done manually someway?
> >
> > Thanks for help in advance!
> >
> > Ryan
>
>
>
> --
> 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
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Re: camel-jackson unmarshalling question

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

No this is not supported today.

Though we could maybe add that, so you can configure this on the data format.

On Mon, Apr 27, 2015 at 1:05 AM, Ryan Moquin <fr...@gmail.com> wrote:
> Hi, I had a question about unmarshalling a json object to a generic class
> type, such as something like, MyClass<Person>.  Due to erasure, Jackson
> provides a special way of unmarshalling this type object so that you don't
> lose the generic type information, like this:
>
> MyClass<Person> myClass = mapper.readValue(json, new
> TypeReference<MyClass<Person>>() {});
>
> Is there anyway to do this with the camel dataformat dsl?  Or does the
> unmarshalling have to be done manually someway?
>
> Thanks for help in advance!
>
> Ryan



-- 
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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/