JSON XStream
Since Camel 2.0
XStream is a Data Format which uses the XStream library to marshal and unmarshal Java objects to and from JSon. However XStream was created primary for working with XML and therefore using JSon with XStream is not as popular as for example Jackson is for JSon.
To use XStream in your camel routes you need to add the a dependency on camel-xstream which implements this data format.
Maven users will need to add the following dependency to their
pom.xml
for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xstream</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
Options
The JSON XStream dataformat supports 3 options, which are listed below.
Name | Default | Java Type | Description |
---|---|---|---|
prettyPrint |
|
|
To enable pretty printing output nicely formatted. Is by default false. |
dropRootNode |
|
|
Whether XStream will drop the root node in the generated JSon. You may want to enable this when using POJOs; as then the written object will include the class name as root node, which is often not intended to be written in the JSON output. |
contentTypeHeader |
|
|
Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc. |