[[json-xstream-dataformat]]
= JSON XStream DataFormat
:docTitle: JSON XStream
:artifactId: camel-xstream
:description: Marshal POJOs to JSON and back using XStream
:since: 2.0
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/dataformats/json-xstream.adoc[opts=optional]

*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 | true | Boolean | Whether the data format should set the Content-Type header with the type from the data format. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON
|===
// 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[]
