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 2012/09/13 13:52:07 UTC

Re: JSON - Jackson return list rather than POJO

Hi

Better late than newer. I have logged a ticket so we wont forget about this
https://issues.apache.org/jira/browse/CAMEL-5604


On Thu, Aug 23, 2012 at 9:01 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Mon, Aug 20, 2012 at 10:42 AM, Jason Chaffee
> <Ja...@betfair.com> wrote:
>> I asked this same question before and this the example and answer I got about using a Map with Jackson.
>>
>
> Yeah I think it uses Map by default.
>
>>
>> <dataFormats>
>>      <!-- here we define a Json data format with the id jack and that it should use the TestPojo as the class type when
>>             doing unmarshal. The unmarshalTypeName is optional, if not provided Camel will use a Map as the type -->
>>      <json id="jack" library="Jackson" unmarshalTypeName="org.apache.camel.component.jackson.TestPojo"/>
>> </dataFormats>
>>
>> I did not test it to confirm that it works correctly though.
>>
>> On Aug 20, 2012, at 1:08 AM, Claus Ibsen <cl...@gmail.com>> wrote:
>>
>> Hi
>>
>> Maybe we could improve the camel-jackson to support list/map types as
>> responses more easily?
>> I just wonder what a good solution would be?
>>
>> Either the user would need to explicit configure this on the data format?
>>
>> Or we can look into a fallback type converter, so Camel automatic an
>> convert to a List/Map for you.
>> And if you want you can use
>>
>> <convertBodyTo type="java.util.List"/>
>>
>> And then the fallback type converter would kick in.
>>
>>
>>
>> On Tue, Aug 14, 2012 at 9:43 PM, ychawla <pr...@yahoo.com>> wrote:
>> A simple workaround for this is a custom bean processor like so:
>>
>>        public void processPersonSearchResponseJSON(Exchange exchange) throws
>> JsonParseException, JsonMappingException, IOException
>>        {
>>                ObjectMapper mapper = new ObjectMapper();
>>
>>                List<PersonSearchResponse> personSearchResponses =
>> mapper.readValue(exchange.getIn().getBody(String.class), new
>> TypeReference<List<PersonSearchResponse>>() { });
>>
>>                exchange.getIn().setBody(personSearchResponses);
>>
>>        }
>>
>> and in the camel context:
>>
>> <camel:to uri="JSONEndpoint"/>
>>
>> <camel:convertBodyTo type="java.lang.String"/>
>>
>> <camel:log message="This is the JSON Response: ${body}" />
>>
>> <camel:to
>> uri="bean:personSearchResponseJSONProcessor?method=processPersonSearchResponseJSON"/>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-tp5717341p5717347.html
>> Sent from the Camel - Users mailing list archive at Nabble.com<http://Nabble.com>.
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com<ma...@fusesource.com>
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>>
>> ________________________________________________________________________
>> In order to protect our email recipients, Betfair Group use SkyScan from
>> MessageLabs to scan all Incoming and Outgoing mail for viruses.
>>
>> ________________________________________________________________________
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JSON - Jackson return list rather than POJO

Posted by yagyesh <ya...@gmail.com>.
Can i get more insight the way this problem is solved ?
I have posted a similar question in camel forum
(http://camel.465427.n5.nabble.com/DataFormat-Versus-TypeConverters-td5747307.html#a5747369)



--
View this message in context: http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-tp5717341p5747370.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: JSON - Jackson return list rather than POJO

Posted by "Daniel Gredler (DHL GM US)" <Da...@dhl.com>.
Ha!

Since the subject was JSON, I had assumed that the pun had to do with HTTP POST, not with forums... hence my follow up pun referencing HTTP GET :-)

Take care,

Daniel


-----Original Message-----
From: yourboogieman [mailto:eric_green86@hotmail.com] 
Sent: Saturday, July 19, 2014 3:19 PM
To: users@camel.apache.org
Subject: RE: JSON - Jackson return list rather than POJO

Well, a forum is a place you post things.  So, it's a bit of a play on words to say, "I'll keep yo posted."


-----Original Message-----
From: Daniel.Gredler@dhl.com
Sent: Thursday, July 17, 2014 2:29 PM
To: users@camel.apache.org
Subject: RE: JSON - Jackson return list rather than POJO

> I'll keep you all posted (pun intended) :)

I don't GET it.


-----Original Message-----
From: yourboogieman [mailto:eric_green86@hotmail.com] 
Sent: Wednesday, July 16, 2014 6:10 PM
To: users@camel.apache.org
Subject: Re: JSON - Jackson return list rather than POJO

I am being held up by this problem also, and I have an idea of how to fix it. 
I'm going to have a crack at CAMEL-5604.  I'll keep you all posted (pun
intended) :)

RE: JSON - Jackson return list rather than POJO

Posted by yourboogieman <er...@hotmail.com>.
Well, a forum is a place you post things.  So, it's a bit of a play on words
to say, "I'll keep yo posted."



--
View this message in context: http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-tp5717341p5754036.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: JSON - Jackson return list rather than POJO

Posted by "Daniel Gredler (DHL GM US)" <Da...@dhl.com>.
> I'll keep you all posted (pun intended) :)

I don't GET it.


-----Original Message-----
From: yourboogieman [mailto:eric_green86@hotmail.com] 
Sent: Wednesday, July 16, 2014 6:10 PM
To: users@camel.apache.org
Subject: Re: JSON - Jackson return list rather than POJO

I am being held up by this problem also, and I have an idea of how to fix it. 
I'm going to have a crack at CAMEL-5604.  I'll keep you all posted (pun
intended) :)



--
View this message in context: http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-tp5717341p5753927.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JSON - Jackson return list rather than POJO

Posted by yourboogieman <er...@hotmail.com>.
I am being held up by this problem also, and I have an idea of how to fix it. 
I'm going to have a crack at CAMEL-5604.  I'll keep you all posted (pun
intended) :)



--
View this message in context: http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-tp5717341p5753927.html
Sent from the Camel - Users mailing list archive at Nabble.com.