= JSON Jackson DataFormat
:doctitle: JSON Jackson
:shortname: json-jackson
:artifactid: camel-jackson
:description: Marshal POJOs to JSON and back using Jackson
:since: 2.0
:supportlevel: Stable
//Manually maintained attributes
:camel-spring-boot-name: jackson

*Since Camel {since}*

Jackson is a Data Format which uses the
https://github.com/FasterXML/jackson-core[Jackson Library]

[source,java]
-------------------------------
from("activemq:My.Queue").
  marshal().json(JsonLibrary.Jackson).
  to("mqseries:Another.Queue");
-------------------------------

== Jackson Options



// dataformat options: START
include::partial$dataformat-options.adoc[]
// dataformat options: END

== Using custom ObjectMapper

You can configure `JacksonDataFormat` to use a custom `ObjectMapper` in case you need more control of the mapping configuration.

If you setup a single `ObjectMapper` in the registry, then Camel will automatic lookup and use this `ObjectMapper`.
For example if you use Spring Boot, then Spring Boot can provide a default `ObjectMapper` for you if you have Spring MVC enabled.
And this would allow Camel to detect that there is one bean of `ObjectMapper` class type in the Spring Boot bean registry
and then use it. When this happens you should set a `INFO` logging from Camel.

== Using Jackson for automatic type conversion

The `camel-jackson` module allows integrating Jackson as a xref:manual::type-converter.adoc[Type Converter].
This works in similar ways that xref:dataformats:jaxb-dataformat.adoc[JAXB] integrates with Camels type converter.

To use this `camel-jackson` must be enabled, which is done by setting the following options
on the `CamelContext` global options, as shown:

[source,java]
----
// Enable Jackson JSON type converter.
camelContext.getGlobalOptions().put("CamelJacksonEnableTypeConverter", "true");
// Allow Jackson JSON to convert to pojo types also
// (by default Jackson only converts to String and other simple types)
getContext().getGlobalOptions().put("CamelJacksonTypeConverterToPojo", "true");
----

The `camel-jackson` type converter integrates with xref:dataformats:jaxb-dataformat.adoc[JAXB]
which means you can annotate POJO class with `JAXB` annotations that Jackson can use.
You can also use Jacksons own annotations on your POJO classes.

== Dependencies

To use Jackson in your camel routes you need to add the dependency
on *camel-jackson* which implements this data format.

If you use maven you could just add the following to your pom.xml,
substituting the version number for the latest & greatest release (see
the download page for the latest versions).

[source,xml]
----------------------------------------------------------
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-jackson</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>
----------------------------------------------------------


include::spring-boot:partial$starter.adoc[]
