THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||
---|---|---|
| ||
<camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:inPojo"/> <marshal ref="gson"/> </route> <route> <from uri="direct:backPojo"/> <unmarshal ref="gson"/> </route> </camelContext> |
Include/Exclude fields using the jsonView
attribute with JacksonDataFormat
Available as of Camel 2.12
As an example of using this attribute you can instead of:
Code Block | ||||
---|---|---|---|---|
| ||||
JacksonDataFormat ageViewFormat = new JacksonDataFormat(TestPojoView.class, Views.Age.class);
from("direct:inPojoAgeView").
marshal(ageViewFormat);
|
Directly specify the JSON view inside the Java DSL as:
Code Block | ||||
---|---|---|---|---|
| ||||
from("direct:inPojoAgeView").
marshal().json(TestPojoView.class, Views.Age.class);
|
And the same in XML DSL:
Code Block | ||||
---|---|---|---|---|
| ||||
<from uri="direct:inPojoAgeView"/>
<marshal>
<json library="Jackson" unmarshalTypeName="org.apache.camel.component.jackson.TestPojoView" jsonView="org.apache.camel.component.jackson.Views$Age"/>
</marshal>
|
Dependencies for XStream
To use JSON in your camel routes you need to add the a dependency on camel-xstream which implements this data format.
...