You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mbhaya <mo...@gmail.com> on 2013/05/18 19:17:41 UTC

Camel JacksonDataFormat configuration in Spring XML

Hi,

I am working on JSON marshalling/unmarshalling and need to exclude certain
POJO fields from marshalling.
I have referred to the following link:
           http://camel.apache.org/json.html

It says that JSON View needs to be used.

And after that we need to specify the following in the java file.

JacksonDataFormat ageViewFormat = new JacksonDataFormat(TestPojoView.class,
Views.Age.class);
from("direct:inPojoAgeView").marshal(ageViewFormat);

I want to specify the above configuration in spring xml file. I know that we
can specify the dataformats in the following way:
 <json id="jack" library="Jackson"
unmarshalTypeName="org.apache.camel.component.jackson.TestPojo"/>
But  I want to configure the JSON view(JacksonDataFormat ageViewFormat = new
JacksonDataFormat(TestPojoView.class, Views.Age.class)) in the spring xml
itself.

Please let me know how to do that.





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-JacksonDataFormat-configuration-in-Spring-XML-tp5732801.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel JacksonDataFormat configuration in Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
I just logged a ticket
https://issues.apache.org/jira/browse/CAMEL-6379

On Sun, May 19, 2013 at 10:04 AM, Claus Ibsen <cl...@gmail.com> wrote:
> In Spring XML you can declare a bean with the json data format and
> configure it the usual spring way
>
> <bean id="json" class="org.apache.camel.component.jackson.JacksonDataFormat">
>  ...
> </bean>
>
> And then in the Camel route you can refer to this data format using
> its id="json"
>
> Something a like:
> <marshal ref="json">
>
> But we should consider adding a jsonView attribute to the <json> so
> you can configure it there also.
> Ideally we should maybe have had a <jackson> instead and not a <json>
> used by both xstream and jackson.
>
>
> On Sat, May 18, 2013 at 7:17 PM, mbhaya <mo...@gmail.com> wrote:
>> Hi,
>>
>> I am working on JSON marshalling/unmarshalling and need to exclude certain
>> POJO fields from marshalling.
>> I have referred to the following link:
>>            http://camel.apache.org/json.html
>>
>> It says that JSON View needs to be used.
>>
>> And after that we need to specify the following in the java file.
>>
>> JacksonDataFormat ageViewFormat = new JacksonDataFormat(TestPojoView.class,
>> Views.Age.class);
>> from("direct:inPojoAgeView").marshal(ageViewFormat);
>>
>> I want to specify the above configuration in spring xml file. I know that we
>> can specify the dataformats in the following way:
>>  <json id="jack" library="Jackson"
>> unmarshalTypeName="org.apache.camel.component.jackson.TestPojo"/>
>> But  I want to configure the JSON view(JacksonDataFormat ageViewFormat = new
>> JacksonDataFormat(TestPojoView.class, Views.Age.class)) in the spring xml
>> itself.
>>
>> Please let me know how to do that.
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-JacksonDataFormat-configuration-in-Spring-XML-tp5732801.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> www.camelone.org: The open source integration conference.
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel JacksonDataFormat configuration in Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
In Spring XML you can declare a bean with the json data format and
configure it the usual spring way

<bean id="json" class="org.apache.camel.component.jackson.JacksonDataFormat">
 ...
</bean>

And then in the Camel route you can refer to this data format using
its id="json"

Something a like:
<marshal ref="json">

But we should consider adding a jsonView attribute to the <json> so
you can configure it there also.
Ideally we should maybe have had a <jackson> instead and not a <json>
used by both xstream and jackson.


On Sat, May 18, 2013 at 7:17 PM, mbhaya <mo...@gmail.com> wrote:
> Hi,
>
> I am working on JSON marshalling/unmarshalling and need to exclude certain
> POJO fields from marshalling.
> I have referred to the following link:
>            http://camel.apache.org/json.html
>
> It says that JSON View needs to be used.
>
> And after that we need to specify the following in the java file.
>
> JacksonDataFormat ageViewFormat = new JacksonDataFormat(TestPojoView.class,
> Views.Age.class);
> from("direct:inPojoAgeView").marshal(ageViewFormat);
>
> I want to specify the above configuration in spring xml file. I know that we
> can specify the dataformats in the following way:
>  <json id="jack" library="Jackson"
> unmarshalTypeName="org.apache.camel.component.jackson.TestPojo"/>
> But  I want to configure the JSON view(JacksonDataFormat ageViewFormat = new
> JacksonDataFormat(TestPojoView.class, Views.Age.class)) in the spring xml
> itself.
>
> Please let me know how to do that.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-JacksonDataFormat-configuration-in-Spring-XML-tp5732801.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen