[[json-xstream-dataformat]]
= JSON XStream DataFormat
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-xstream/src/main/docs/json-xstream-dataformat.adoc
:docTitle: JSON XStream
:artifactId: camel-xstream
:description: Marshal POJOs to JSON and back.
:since: 2.0
:supportLevel: Stable

*Since Camel {since}*

XStream is a Data Format which uses the
http://xstream.codehaus.org/[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:

[source,xml]
----------------------------------------------------------
<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

// dataformat options: START
The JSON XStream dataformat supports 3 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| prettyPrint | false | Boolean | To enable pretty printing output nicely formatted. Is by default false.
| dropRootNode | false | Boolean | 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 | false | Boolean | 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.
|===
// dataformat options: END


== Using the Java DSL

[source,java]
-----------------------------------------------------------
// lets turn Object messages into XML then send to MQSeries
from("activemq:My.Queue").
  marshal().json(JsonLibrary.XStream).
  to("mqseries:Another.Queue");
-----------------------------------------------------------

include::camel-spring-boot::page$xstream-starter.adoc[]
