Modified: websites/production/camel/content/json.html
==============================================================================
--- websites/production/camel/content/json.html (original)
+++ websites/production/camel/content/json.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: JSON
@@ -86,100 +75,39 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="JSON-JSON">JSON</h2><p>JSON is a 
<a shape="rect" href="data-format.html">Data Format</a> to marshal and 
unmarshal Java objects to and from <a shape="rect" class="external-link" 
href="http://www.json.org/"; rel="nofollow">JSON</a>.</p><p>For JSON to object 
marshalling, Camel provides integration with three popular JSON 
libraries:</p><ul class="alternate"><li>The <a shape="rect" 
class="external-link" href="http://xstream.codehaus.org/"; 
rel="nofollow">XStream library</a> and <a shape="rect" class="external-link" 
href="http://jettison.codehaus.org/"; rel="nofollow">Jettsion </a></li><li>The 
<a shape="rect" class="external-link" 
href="https://github.com/FasterXML/jackson"; rel="nofollow">Jackson 
library</a></li><li><strong>Camel 2.10:</strong> The <a shape="rect" 
class="external-link" href="http://code.google.com/p/google-gson/"; 
rel="nofollow">GSon library</a></li></ul><p>Every library requires adding the 
special camel component (see "Dependency
 ..." paragraphs further down). By default Camel uses the XStream 
library.</p><div class="confluence-information-macro 
confluence-information-macro-tip"><p class="title">Direct, bi-directional JSON 
&lt;=&gt; XML conversions</p><span class="aui-icon aui-icon-small 
aui-iconfont-approve confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>As of Camel 2.10, Camel supports 
direct, bi-directional JSON &lt;=&gt; XML conversions via the <a shape="rect" 
href="xmljson.html">camel-xmljson</a> data format, which is documented 
separately.</p></div></div><h3 
id="JSON-UsingJSONDataFormatWiththeXStreamLibrary">Using JSON Data Format With 
the&#160;<code>XStream</code> Library</h3><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// Let&#39;s turn Object messages into JSON 
then send to MQSeries
-from(&quot;activemq:My.Queue&quot;)
+<div class="wiki-content maincontent"><h2 id="JSON-JSON">JSON</h2><p>JSON is a 
<a shape="rect" href="data-format.html">Data Format</a> to marshal and 
unmarshal Java objects to and from <a shape="rect" class="external-link" 
href="http://www.json.org/"; rel="nofollow">JSON</a>.</p><p>For JSON to object 
marshalling, Camel provides integration with three popular JSON 
libraries:</p><ul class="alternate"><li>The <a shape="rect" 
class="external-link" href="http://xstream.codehaus.org/"; 
rel="nofollow">XStream library</a> and <a shape="rect" class="external-link" 
href="http://jettison.codehaus.org/"; rel="nofollow">Jettsion </a></li><li>The 
<a shape="rect" class="external-link" 
href="https://github.com/FasterXML/jackson"; rel="nofollow">Jackson 
library</a></li><li><strong>Camel 2.10:</strong> The <a shape="rect" 
class="external-link" href="http://code.google.com/p/google-gson/"; 
rel="nofollow">GSon library</a></li></ul><p>Every library requires adding the 
special camel component (see "Dependency
 ..." paragraphs further down). By default Camel uses the XStream 
library.</p><parameter ac:name="title">Direct, bi-directional JSON &lt;=&gt; 
XML conversions</parameter><rich-text-body><p>As of Camel 2.10, Camel supports 
direct, bi-directional JSON &lt;=&gt; XML conversions via the <a shape="rect" 
href="xmljson.html">camel-xmljson</a> data format, which is documented 
separately.</p></rich-text-body><h3 
id="JSON-UsingJSONDataFormatWiththeXStreamLibrary">Using JSON Data Format With 
the&#160;<code>XStream</code> Library</h3><parameter 
ac:name="language">java</parameter><plain-text-body>// Let's turn Object 
messages into JSON then send to MQSeries
+from("activemq:My.Queue")
   .marshal().json()
-  .to(&quot;mqseries:Another.Queue&quot;);
-]]></script>
-</div></div><h3 id="JSON-UsingJSONDataFormatWiththeJacksonLibrary">Using JSON 
Data Format With the&#160;<code>Jackson</code> Library</h3><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// Let&#39;s turn Object messages into JSON 
then send to MQSeries
-from(&quot;activemq:My.Queue&quot;)
+  .to("mqseries:Another.Queue");
+</plain-text-body><h3 id="JSON-UsingJSONDataFormatWiththeJacksonLibrary">Using 
JSON Data Format With the&#160;<code>Jackson</code> Library</h3><parameter 
ac:name="language">java</parameter><plain-text-body>// Let's turn Object 
messages into JSON then send to MQSeries
+from("activemq:My.Queue")
   .marshal().json(JsonLibrary.Jackson)
-  .to(&quot;mqseries:Another.Queue&quot;);
-]]></script>
-</div></div><h3 id="JSON-UsingJSONDataFormatWiththeGSONLibrary">Using JSON 
Data Format With the GSON Library</h3><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// Let&#39;s turn Object messages into JSON 
then send to MQSeries
-from(&quot;activemq:My.Queue&quot;)
+  .to("mqseries:Another.Queue");
+</plain-text-body><h3 id="JSON-UsingJSONDataFormatWiththeGSONLibrary">Using 
JSON Data Format With the GSON Library</h3><parameter 
ac:name="language">java</parameter><plain-text-body>// Let's turn Object 
messages into JSON then send to MQSeries
+from("activemq:My.Queue")
   .marshal().json(JsonLibrary.Gson)
-  .to(&quot;mqseries:Another.Queue&quot;);
-]]></script>
-</div></div><h4 id="JSON-UsingJSONinSpringDSL">Using JSON in Spring 
DSL</h4><p>When using <a shape="rect" href="data-format.html">Data Format</a> 
in Spring DSL you need to declare the data formats first. This is done in the 
<strong><code>DataFormats</code></strong> XML tag.</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
+  .to("mqseries:Another.Queue");
+</plain-text-body><h4 id="JSON-UsingJSONinSpringDSL">Using JSON in Spring 
DSL</h4><p>When using <a shape="rect" href="data-format.html">Data Format</a> 
in Spring DSL you need to declare the data formats first. This is done in the 
<strong><code>DataFormats</code></strong> XML tag.</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
   &lt;!-- 
        Here we define a Json data format with the id jack and that it should 
use the TestPojo
        as the class type when doing unmarshal.
 
        The unmarshalTypeName is optional, if not provided Camel will use a Map 
as the type.
   --&gt;
-  &lt;json id=&quot;jack&quot; library=&quot;Jackson&quot; 
unmarshalTypeName=&quot;org.apache.camel.component.jackson.TestPojo&quot;/&gt;
+  &lt;json id="jack" library="Jackson" 
unmarshalTypeName="org.apache.camel.component.jackson.TestPojo"/&gt;
 &lt;/dataFormats&gt;
-]]></script>
-</div></div><p>And then you can refer to this id in the route:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;route&gt;
-  &lt;from uri=&quot;direct:back&quot;/&gt;
-  &lt;unmarshal ref=&quot;jack&quot;/&gt;
-  &lt;to uri=&quot;mock:reverse&quot;/&gt;
+</plain-text-body><p>And then you can refer to this id in the 
route:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;route&gt;
+  &lt;from uri="direct:back"/&gt;
+  &lt;unmarshal ref="jack"/&gt;
+  &lt;to uri="mock:reverse"/&gt;
 &lt;/route&gt;
-]]></script>
-</div></div><h3 id="JSON-ExcludingPOJOFieldsFromMarshalling">Excluding POJO 
Fields From Marshalling</h3><p><strong>As of Camel 2.10</strong><br 
clear="none"> When marshaling a POJO to JSON you might want to exclude certain 
fields from the JSON output. With Jackson you can use <a shape="rect" 
class="external-link" href="http://wiki.fasterxml.com/JacksonJsonViews"; 
rel="nofollow">JSON views</a> to accomplish this.</p><p>First create one or 
more marker classes:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public class Views {
-
-    static class Age { }
-    static class Weight { }
-}
-]]></script>
-</div></div>Second, use the marker classes with the 
<strong><code>@JsonView</code></strong> annotation to include/exclude certain 
fields. The annotation also works on getters:<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-@JsonView(Views.Age.class)
-private int age = 30;
-
-private int height = 190;
-
-@JsonView(Views.Weight.class)
-private int weight = 70;
-]]></script>
-</div></div>Finally, use the Camel 
<strong><code>JacksonDataFormat</code></strong> to marshal the above POJO to 
JSON.<div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:inPojoAgeView&quot;).marshal().json(TestPojoView.class, 
Views.Age.class);
-]]></script>
-</div></div><strong>Note</strong>: the height field is missing in the 
resulting JSON.<div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[{&quot;age&quot;:30, &quot;weight&quot;:70}
-]]></script>
-</div></div><p>The GSON library supports a similar feature through the notion 
of <a shape="rect" class="external-link" 
href="http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/ExclusionStrategy.html";
 rel="nofollow">ExclusionStrategies</a>:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-/**
- * Strategy to exclude {@link ExcludeAge} annotated fields
- */
-protected static class AgeExclusionStrategy implements ExclusionStrategy {
-
-    @Override
-    public boolean shouldSkipField(FieldAttributes f) {
-        return f.getAnnotation(ExcludeAge.class) != null;
-    }
-
-    @Override
-    public boolean shouldSkipClass(Class&lt;?&gt; clazz) {
-        return false;
-    }
-}
-]]></script>
-</div></div>The <strong><code>GsonDataFormat</code></strong> accepts an 
<strong><code>ExclusionStrategy</code></strong> in its constructor:<div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-GsonDataFormat ageExclusionFormat = new 
GsonDataFormat(TestPojoExclusion.class);
-ageExclusionFormat.setExclusionStrategies(Arrays.&lt;ExclusionStrategy&gt;asList(new
 AgeExclusionStrategy()));
-from(&quot;direct:inPojoExcludeAge&quot;).marshal(ageExclusionFormat);
-]]></script>
-</div></div>The line above will exclude fields annotated with 
<strong><code>@ExcludeAge</code></strong> when marshaling to JSON.<h3 
id="JSON-ConfiguringFieldNamingPolicy">Configuring Field Naming 
Policy</h3><p><strong>Available as of Camel 2.11</strong></p><p>The GSON 
library supports specifying policies and strategies for mapping from JSON to 
POJO fields. A common naming convention is to map JSON fields using lower case 
with underscores.</p><p>We may have this JSON string</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[{
-  &quot;id&quot; : 123,
-  &quot;first_name&quot; : &quot;Donald&quot;
-  &quot;last_name&quot; : &quot;Duck&quot;
+</plain-text-body><h3 id="JSON-ExcludingPOJOFieldsFromMarshalling">Excluding 
POJO Fields From Marshalling</h3><p><strong>As of Camel 2.10</strong><br 
clear="none"> When marshaling a POJO to JSON you might want to exclude certain 
fields from the JSON output. With Jackson you can use <a shape="rect" 
class="external-link" href="http://wiki.fasterxml.com/JacksonJsonViews"; 
rel="nofollow">JSON views</a> to accomplish this.</p><p>First create one or 
more marker 
classes:<plain-text-body>{snippet:id=marker|lang=java|url=camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/Views.java}</plain-text-body>Second,
 use the marker classes with the <strong><code>@JsonView</code></strong> 
annotation to include/exclude certain fields. The annotation also works on 
getters:<plain-text-body>{snippet:id=jsonview|lang=java|url=camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java}</plain-text-body>Finally,
 use the Camel <stro
 ng><code>JacksonDataFormat</code></strong> to marshal the above POJO to 
JSON.<plain-text-body>{snippet:id=format|lang=java|url=camel/trunk/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalViewTest.java}</plain-text-body><strong>Note</strong>:
 the height field is missing in the resulting 
JSON.</p><plain-text-body>{"age":30, "weight":70}
+</plain-text-body><p>The GSON library supports a similar feature through the 
notion of <a shape="rect" class="external-link" 
href="http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/ExclusionStrategy.html";
 
rel="nofollow">ExclusionStrategies</a>:<plain-text-body>{snippet:id=strategy|lang=java|url=camel/trunk/components/camel-gson/src/test/java/org/apache/camel/component/gson/GsonMarshalExclusionTest.java}</plain-text-body>The
 <strong><code>GsonDataFormat</code></strong> accepts an 
<strong><code>ExclusionStrategy</code></strong> in its 
constructor:<plain-text-body>{snippet:id=format|lang=java|url=camel/trunk/components/camel-gson/src/test/java/org/apache/camel/component/gson/GsonMarshalExclusionTest.java}</plain-text-body>The
 line above will exclude fields annotated with 
<strong><code>@ExcludeAge</code></strong> when marshaling to JSON.</p><h3 
id="JSON-ConfiguringFieldNamingPolicy">Configuring Field Naming 
Policy</h3><p><strong>Available as of Camel 2.11</s
 trong></p><p>The GSON library supports specifying policies and strategies for 
mapping from JSON to POJO fields. A common naming convention is to map JSON 
fields using lower case with underscores.</p><p>We may have this JSON 
string</p><plain-text-body>{
+  "id" : 123,
+  "first_name" : "Donald"
+  "last_name" : "Duck"
 }
-]]></script>
-</div></div><p>Which we want to map to a POJO that has getter/setters 
as:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>PersonPojo.java</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[public class PersonPojo {
+</plain-text-body><p>Which we want to map to a POJO that has getter/setters 
as:</p><parameter ac:name="language">java</parameter><parameter 
ac:name="java:title">PersonPojo.java</parameter><parameter 
ac:name="title">PersonPojo.java</parameter><plain-text-body>public class 
PersonPojo {
 
     private int id;
     private String firstName;
@@ -209,153 +137,102 @@ from(&quot;direct:inPojoExcludeAge&quot;
         this.lastName = lastName;
     }
 }
-]]></script>
-</div></div><p>Then we can configure the 
<strong><code>org.apache.camel.component.gson.GsonDataFormat</code></strong> in 
a Spring XML files as shown below. Notice we use 
<strong><code>fieldNamingPolicy</code></strong> property to set the field 
mapping. This property is an enum from GSon 
<strong><code>com.google.gson.FieldNamingPolicy</code></strong> which has a 
number of predefined mappings.</p><p>If you need full control you can use the 
property <strong><code>FieldNamingStrategy</code></strong> and implement a 
custom <strong><code>com.google.gson.FieldNamingStrategy</code></strong> where 
you can control the mapping.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Configuring GsonDataFromat in Spring XML 
file</b></div><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;!-- define the gson data format, where we 
configure the data format using the properties --&gt;
-&lt;bean id=&quot;gson&quot; 
class=&quot;org.apache.camel.component.gson.GsonDataFormat&quot;&gt;
+</plain-text-body><p>Then we can configure the 
<strong><code>org.apache.camel.component.gson.GsonDataFormat</code></strong> in 
a Spring XML files as shown below. Notice we use 
<strong><code>fieldNamingPolicy</code></strong> property to set the field 
mapping. This property is an enum from GSon 
<strong><code>com.google.gson.FieldNamingPolicy</code></strong> which has a 
number of predefined mappings.</p><p>If you need full control you can use the 
property <strong><code>FieldNamingStrategy</code></strong> and implement a 
custom <strong><code>com.google.gson.FieldNamingStrategy</code></strong> where 
you can control the mapping.</p><parameter ac:name="xml:title">Configuring 
GsonDataFormat in Spring XML file</parameter><parameter 
ac:name="language">xml</parameter><parameter ac:name="title">Configuring 
GsonDataFromat in Spring XML file</parameter><plain-text-body>&lt;!-- define 
the gson data format, where we configure the data format using the properties 
--&gt;
+&lt;bean id="gson" class="org.apache.camel.component.gson.GsonDataFormat"&gt;
 
   &lt;!-- we want to unmarshal to person pojo --&gt;
-  &lt;property name=&quot;unmarshalType&quot; 
value=&quot;org.apache.camel.component.gson.PersonPojo&quot;/&gt;
+  &lt;property name="unmarshalType" 
value="org.apache.camel.component.gson.PersonPojo"/&gt;
 
   &lt;!-- we want to map fields to use lower case and underscores --&gt;
-  &lt;property name=&quot;fieldNamingPolicy&quot; 
value=&quot;LOWER_CASE_WITH_UNDERSCORES&quot;/&gt;
+  &lt;property name="fieldNamingPolicy" 
value="LOWER_CASE_WITH_UNDERSCORES"/&gt;
 &lt;/bean&gt;
-]]></script>
-</div></div><p>And use it in Camel routes by referring to its bean id as 
shown:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Using 
gson from Camel Routes</b></div><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;camelContext 
xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
+</plain-text-body><p>And use it in Camel routes by referring to its bean id as 
shown:</p><parameter ac:name="xml:title">Using gson from Camel 
routes</parameter><parameter ac:name="language">xml</parameter><parameter 
ac:name="title">Using gson from Camel 
Routes</parameter><plain-text-body>&lt;camelContext 
xmlns="http://camel.apache.org/schema/spring"&gt;
   &lt;route&gt;
-    &lt;from uri=&quot;direct:inPojo&quot;/&gt;
-    &lt;marshal ref=&quot;gson&quot;/&gt;
+    &lt;from uri="direct:inPojo"/&gt;
+    &lt;marshal ref="gson"/&gt;
   &lt;/route&gt;
 
   &lt;route&gt;
-    &lt;from uri=&quot;direct:backPojo&quot;/&gt;
-    &lt;unmarshal ref=&quot;gson&quot;/&gt;
+    &lt;from uri="direct:backPojo"/&gt;
+    &lt;unmarshal ref="gson"/&gt;
   &lt;/route&gt;
 &lt;/camelContext&gt;
-]]></script>
-</div></div><h3 
id="JSON-Include/ExcludeFieldsUsingthejsonViewAttributeWithJacksonDataFormat">Include/Exclude
 Fields Using the <strong><code>jsonView</code></strong> Attribute With 
<code>JacksonDataFormat</code></h3><p><strong>Available as of Camel 
2.12</strong></p><p>As an example of using this attribute you can instead 
of:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[JacksonDataFormat ageViewFormat = new 
JacksonDataFormat(TestPojoView.class, Views.Age.class);
+</plain-text-body><h3 
id="JSON-Include/ExcludeFieldsUsingthejsonViewAttributeWithJacksonDataFormat">Include/Exclude
 Fields Using the <strong><code>jsonView</code></strong> Attribute With 
<code>JacksonDataFormat</code></h3><p><strong>Available as of Camel 
2.12</strong></p><p>As an example of using this attribute you can instead 
of:</p><parameter 
ac:name="language">java</parameter><plain-text-body>JacksonDataFormat 
ageViewFormat = new JacksonDataFormat(TestPojoView.class, Views.Age.class);
 
-from(&quot;direct:inPojoAgeView&quot;)
+from("direct:inPojoAgeView")
   .marshal(ageViewFormat);
-]]></script>
-</div></div><p>Directly specify your <a shape="rect" class="external-link" 
href="http://wiki.fasterxml.com/JacksonJsonViews"; rel="nofollow">JSON view</a> 
inside the Java DSL as:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[from(&quot;direct:inPojoAgeView&quot;)
+</plain-text-body><p>Directly specify your <a shape="rect" 
class="external-link" href="http://wiki.fasterxml.com/JacksonJsonViews"; 
rel="nofollow">JSON view</a> inside the Java DSL as:</p><parameter 
ac:name="language">java</parameter><plain-text-body>from("direct:inPojoAgeView")
   .marshal().json(TestPojoView.class, Views.Age.class);
-]]></script>
-</div></div><p>And the same in XML DSL:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;from 
uri=&quot;direct:inPojoAgeView&quot;/&gt;
+</plain-text-body><p>And the same in XML DSL:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;from 
uri="direct:inPojoAgeView"/&gt;
   &lt;marshal&gt;
-    &lt;json library=&quot;Jackson&quot; 
unmarshalTypeName=&quot;org.apache.camel.component.jackson.TestPojoView&quot; 
jsonView=&quot;org.apache.camel.component.jackson.Views$Age&quot;/&gt;
+    &lt;json library="Jackson" 
unmarshalTypeName="org.apache.camel.component.jackson.TestPojoView" 
jsonView="org.apache.camel.component.jackson.Views$Age"/&gt;
   &lt;/marshal&gt;
-]]></script>
-</div></div><h3 
id="JSON-SettingSerializationIncludeOptionforJacksonMarshal">Setting 
Serialization Include Option for Jackson Marshal</h3><p><strong>Available as of 
Camel 2.13.3/2.14</strong></p><p>If you want to marshal a POJO to JSON, and 
the&#160;POJO has some fields with null values. And you want to skip these null 
values, then you need to set either an annotation on the POJO,&#160;</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[@JsonInclude(Include.NON_NULL)
+</plain-text-body><h3 
id="JSON-SettingSerializationIncludeOptionforJacksonMarshal">Setting 
Serialization Include Option for Jackson Marshal</h3><p><strong>Available as of 
Camel 2.13.3/2.14</strong></p><p>If you want to marshal a POJO to JSON, and 
the&#160;POJO has some fields with null values. And you want to skip these null 
values, then you need to set either an annotation on the 
POJO,&#160;</p><parameter 
ac:name="language">java</parameter><plain-text-body>@JsonInclude(Include.NON_NULL)
 public class MyPojo {
    // ...
-}]]></script>
-</div></div><p>But this requires you to include that annotation in 
your&#160;POJO source code. You can also configure the 
Camel&#160;<strong><code>JsonDataFormat</code></strong> to set the include 
option, as shown below:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[JacksonDataFormat format = new 
JacksonDataFormat();
-format.setInclude(&quot;NON_NULL&quot;);]]></script>
-</div></div><p>Or from XML DSL you configure this as</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
include=&quot;NON_NULL&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><h3 
id="JSON-UnmarshalingfromJSONtoPOJOwithDynamicClassName">Unmarshaling from JSON 
to POJO with Dynamic Class Name</h3><p><strong>Available as of Camel 
2.14</strong></p><p>If you use Jackson to unmarshal JSON to POJO, then you can 
now specify a header in the message that indicate which class name to unmarshal 
to.<span style="line-height: 1.4285715;"> The header has key 
</span><strong><code style="line-height: 
1.4285715;">CamelJacksonUnmarshalType</code></strong><span style="line-height: 
1.4285715;">&#160;if that header is present in the message, then Jackson will 
use that as FQN for the POJO class to unmarshal the JSON payload as. Notice 
that behavior is enabled out of the box from <strong>Camel 
2.14</strong>.&#160;</span></p><p><span style="line-height: 
1.4285715;">&#160;</span><span style="line-height: 1.4285715;">For JMS end 
users there is the&#160;<strong><code>JMSType</code></strong> header from the 
JMS spec that indicates that also. To enable support for&#160;<spa
 n><strong><code>JMSType</code></strong></span> you would need to turn that on, 
on the Jackson data format as shown:</span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[JacksonDataFormat format = new 
JacksonDataFormat();
-format.setAllowJmsType(true);]]></script>
-</div></div><p>Or from XML DSL you configure this as</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
allowJmsType=&quot;true&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><h3 
id="JSON-UnmarshalingFromJSONtoList&lt;Map&gt;orList&lt;pojo&gt;">Unmarshaling 
From JSON to&#160;<code>List&lt;Map&gt;</code> 
or&#160;<code>List&lt;pojo&gt;</code></h3><p><strong>Available as of Camel 
2.14</strong></p><p>If you are using Jackson to unmarshal JSON to a list of 
map/POJO, you can now specify this by 
setting&#160;<strong><code>useList="true"</code></strong> or use 
the&#160;<strong><code>org.apache.camel.component.jackson.ListJacksonDataFormat</code></strong>.</p><p>For
 example, with Java you can do as shown below:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[JacksonDataFormat format = new 
ListJacksonDataFormat();
+}</plain-text-body><p>But this requires you to include that annotation in 
your&#160;POJO source code. You can also configure the 
Camel&#160;<strong><code>JsonDataFormat</code></strong> to set the include 
option, as shown below:</p><parameter 
ac:name="language">java</parameter><plain-text-body>JacksonDataFormat format = 
new JacksonDataFormat();
+format.setInclude("NON_NULL");</plain-text-body><p>Or from XML DSL you 
configure this as</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" include="NON_NULL"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><h3 
id="JSON-UnmarshalingfromJSONtoPOJOwithDynamicClassName">Unmarshaling from JSON 
to POJO with Dynamic Class Name</h3><p><strong>Available as of Camel 
2.14</strong></p><p>If you use Jackson to unmarshal JSON to POJO, then you can 
now specify a header in the message that indicate which class name to unmarshal 
to.<span style="line-height: 1.4285715;"> The header has key 
</span><strong><code style="line-height: 
1.4285715;">CamelJacksonUnmarshalType</code></strong><span style="line-height: 
1.4285715;">&#160;if that header is present in the message, then Jackson will 
use that as FQN for the POJO class to unmarshal the JSON payload as. Notice 
that behavior is enabled out of the box from <strong>Camel 
2.14</strong>.&#160;</span></p><p><span style="line-height: 
1.4285715;">&#160;</span><span style="line-height: 1.4285715;">For JMS end 
users there is the&#160;<strong><code>JMSType</code></strong> header from the 
JMS spec that indicates that also. To en
 able support for&#160;<span><strong><code>JMSType</code></strong></span> you 
would need to turn that on, on the Jackson data format as 
shown:</span></p><parameter 
ac:name="language">java</parameter><plain-text-body>JacksonDataFormat format = 
new JacksonDataFormat();
+format.setAllowJmsType(true);</plain-text-body><p>Or from XML DSL you 
configure this as</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" allowJmsType="true"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><h3 
id="JSON-UnmarshalingFromJSONtoList&lt;Map&gt;orList&lt;pojo&gt;">Unmarshaling 
From JSON to&#160;<code>List&lt;Map&gt;</code> 
or&#160;<code>List&lt;pojo&gt;</code></h3><p><strong>Available as of Camel 
2.14</strong></p><p>If you are using Jackson to unmarshal JSON to a list of 
map/POJO, you can now specify this by 
setting&#160;<strong><code>useList="true"</code></strong> or use 
the&#160;<strong><code>org.apache.camel.component.jackson.ListJacksonDataFormat</code></strong>.</p><p>For
 example, with Java you can do as shown below:</p><parameter 
ac:name="language">java</parameter><plain-text-body>JacksonDataFormat format = 
new ListJacksonDataFormat();
 // or
 JacksonDataFormat format = new JacksonDataFormat();
 format.useList();
 
 // and you can specify the pojo class type also
-format.setUnmarshalType(MyPojo.class);]]></script>
-</div></div><p>And if you use XML DSL then you configure to use list using 
<code>useList</code> attribute as shown below:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
useList=&quot;true&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p>And you can specify the pojo type also</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
useList=&quot;true&quot; unmarshalTypeName=&quot;com.foo.MyPojo&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><h3 id="JSON-UsingCustomJackson'sObjectMapper">Using Custom 
Jackson's <code>ObjectMapper</code></h3><p><strong>Available from Camel 
2.17</strong></p><p>You can use custom 
Jackson&#160;<strong><code>ObjectMapper</code></strong> instance, can be 
configured as shown below.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
objectMapper=&quot;myMapper&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p>Where&#160;<strong><code>myMapper</code></strong> is the id of 
the custom instance that Camel will lookup in the&#160;<a shape="rect" 
href="registry.html">Registry.</a></p><h3 
id="JSON-UsingCustomJacksonModules">Using Custom Jackson 
Modules</h3><p><strong>Available as of Camel 2.15</strong></p><p>You can use 
custom Jackson modules by specifying the class names of those using 
the&#160;<strong><code>moduleClassNames</code></strong> option as shown 
below.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
useList=&quot;true&quot; unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
moduleClassNames=&quot;com.foo.MyModule,com.foo.MyOtherModule&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p>When using&#160;<strong><code>moduleClassNames</code></strong> 
then the custom Jackson modules are not configured, by created using default 
constructor and used as-is. If a custom module needs any custom configuration, 
then an instance of the module can be created and configured, and then 
use&#160;<strong><code>modulesRefs</code></strong> to refer to the module as 
shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;myJacksonModule&quot; 
class=&quot;com.foo.MyModule&quot;&gt;
+format.setUnmarshalType(MyPojo.class);</plain-text-body><p>And if you use XML 
DSL then you configure to use list using <code>useList</code> attribute as 
shown below:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" useList="true"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p>And you can specify the pojo type 
also</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" useList="true" 
unmarshalTypeName="com.foo.MyPojo"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><h3 
id="JSON-UsingCustomJackson'sObjectMapper">Using Custom Jackson's 
<code>ObjectMapper</code></h3><p><strong>Available from Camel 
2.17</strong></p><p>You can use custom 
Jackson&#160;<strong><code>ObjectMapper</code></strong> instance, can be 
configured as shown below.</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" objectMapper="myMapper"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p>Where&#160;<strong><code>myMapper</code></strong>
 is the id of the custom instance that Camel will lookup in the&#160;<a 
shape="rect" href="registry.html">Registry.</a></p><h3 
id="JSON-UsingCustomJacksonModules">Using Custom Jackson 
Modules</h3><p><strong>Available as of Camel 2.15</strong></p><p>You can use 
custom Jackson modules by specifying the class names of those using 
the&#160;<strong><code>moduleClassNames</code></strong> option as shown 
below.</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" useList="true" 
unmarshalTypeName="com.foo.MyPojo" 
moduleClassNames="com.foo.MyModule,com.foo.MyOtherModule"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p>When 
using&#160;<strong><code>moduleClassNames</code></strong> then the custom 
Jackson modules are not configured, by created using default constructor and 
used as-is. If a custom module needs any custom configuration, then an instance 
of the module can be created and configured, and then 
use&#160;<strong><code>modulesRefs</code></strong> to refer to the module as 
shown below:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;bean 
id="myJacksonModule" class="com.foo.MyModule"&gt;
   ... // configure the module as you want
 &lt;/bean&gt;
- 
+&#160;
 &lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
useList=&quot;true&quot; unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
moduleRefs=&quot;myJacksonModule&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p>&#160;Multiple modules can be specified separated by comma, 
such as 
<strong><code>moduleRefs="myJacksonModule,myOtherModule"</code></strong>.</p><h3
 id="JSON-EnablingorDisableFeaturesUsingJackson">Enabling or Disable Features 
Using Jackson</h3><p><strong>Available as of Camel 2.15</strong></p><p>Jackson 
has a number of features you can enable or disable, which 
its&#160;<strong><code>ObjectMapper</code></strong> uses. For example to 
disable failing on unknown properties when marshaling, you can configure this 
using the <strong><code>disableFeatures</code></strong>:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; 
unmarshalTypeName=&quot;com.foo.MyPojo&quot; 
disableFeatures=&quot;FAIL_ON_UNKNOWN_PROPERTIES&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p>You can disable multiple features by separating the values 
using comma. The values for the features must be the name of the enums from 
Jackson from the following enum 
classes</p><ul><li><code>com.fasterxml.jackson.databind.SerializationFeature</code></li><li><code>com.fasterxml.jackson.databind.DeserializationFeature</code></li><li><code>com.fasterxml.jackson.databind.MapperFeature</code></li></ul><p>To
 enable a feature use the&#160;<strong><code>enableFeatures</code></strong> 
options instead.</p><p>From Java code you can use the type safe methods 
from&#160;<strong><code>camel-jackson</code></strong> module:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[JacksonDataFormat df = new 
JacksonDataFormat(MyPojo.class);
+  &lt;json id="json" library="Jackson" useList="true" 
unmarshalTypeName="com.foo.MyPojo" moduleRefs="myJacksonModule"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p>&#160;Multiple modules can be 
specified separated by comma, such as 
<strong><code>moduleRefs="myJacksonModule,myOtherModule"</code></strong>.</p><h3
 id="JSON-EnablingorDisableFeaturesUsingJackson">Enabling or Disable Features 
Using Jackson</h3><p><strong>Available as of Camel 2.15</strong></p><p>Jackson 
has a number of features you can enable or disable, which 
its&#160;<strong><code>ObjectMapper</code></strong> uses. For example to 
disable failing on unknown properties when marshaling, you can configure this 
using the <strong><code>disableFeatures</code></strong>:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="json" library="Jackson" unmarshalTypeName="com.foo.MyPojo" 
disableFeatures="FAIL_ON_UNKNOWN_PROPERTIES"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p>You can disable multiple features by 
separating the values using comma. The values for the features must be the name 
of the enums from Jackson from the following enum 
classes</p><ul><li><code>com.fasterxml.jackson.databind.SerializationFeature</code></li><li><code>com.fasterxml.jackson.databind.DeserializationFeature</code></li><li><code>com.fasterxml.jackson.databind.MapperFeature</code></li></ul><p>To
 enable a feature use the&#160;<strong><code>enableFeatures</code></strong> 
options instead.</p><p>From Java code you can use the type safe methods 
from&#160;<strong><code>camel-jackson</code></strong> module:</p><parameter 
ac:name="language">java</parameter><plain-text-body>JacksonDataFormat df = new 
JacksonDataFormat(MyPojo.class);
 df.disableFeature(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-df.disableFeature(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);]]></script>
-</div></div><h3 id="JSON-ConvertingMapstoPOJOUsingJackson">Converting Maps to 
POJO Using Jackson</h3><p>Available since <strong>Camel 2.16</strong>. Jackson 
<strong><code>ObjectMapper</code></strong> can be used to convert maps to POJO 
objects. Jackson component comes with the data converter that can be used to 
convert <strong><code>java.util.Map</code></strong> instance to non-String, 
non-primitive and non-Number objects.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[Map&lt;String, Object&gt; invoiceData = new 
HashMap&lt;String, Object&gt;();
-invoiceData.put(&quot;netValue&quot;, 500);
-producerTemplate.sendBody(&quot;direct:mapToInvoice&quot;, invoiceData);
+df.disableFeature(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);</plain-text-body><h3
 id="JSON-ConvertingMapstoPOJOUsingJackson">Converting Maps to POJO Using 
Jackson</h3><p>Available since <strong>Camel 2.16</strong>. Jackson 
<strong><code>ObjectMapper</code></strong> can be used to convert maps to POJO 
objects. Jackson component comes with the data converter that can be used to 
convert <strong><code>java.util.Map</code></strong> instance to non-String, 
non-primitive and non-Number objects.</p><parameter 
ac:name="language">java</parameter><plain-text-body>Map&lt;String, Object&gt; 
invoiceData = new HashMap&lt;String, Object&gt;();
+invoiceData.put("netValue", 500);
+producerTemplate.sendBody("direct:mapToInvoice", invoiceData);
 ...
 // Later in the processor
-Invoice invoice = exchange.getIn().getBody(Invoice.class);]]></script>
-</div></div><p>If there is a single <strong><code>ObjectMapper</code></strong> 
instance available in the Camel registry, it will used by the converter to 
perform the conversion. Otherwise the default mapper will be used. 
&#160;</p><h3 id="JSON-FormattedJSONmarshalling(pretty-printing)">Formatted 
JSON marshalling (pretty-printing)</h3><p><strong>Available as of Camel 
2.16</strong></p><p>Using the <strong><code>prettyPrint</code></strong> 
option&#160;one can output a well formatted JSON while marshaling:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dataFormats&gt;
-  &lt;json id=&quot;xstream&quot; prettyPrint=&quot;true&quot;/&gt;
-  &lt;json id=&quot;jackson&quot; prettyPrint=&quot;true&quot; 
library=&quot;Jackson&quot;/&gt;
-  &lt;json id=&quot;gson&quot; prettyPrint=&quot;true&quot; 
library=&quot;Gson&quot;/&gt;
-&lt;/dataFormats&gt;]]></script>
-</div></div><p><span style="line-height: 1.5625;">And in Java 
DSL:</span></p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[from(&quot;direct:inPretty&quot;).marshal().json(true);
- 
-from(&quot;direct:inPretty&quot;).marshal().json(JsonLibrary.Jackson, true);
- 
-from(&quot;direct:inPretty&quot;).marshal().json(JsonLibrary.Gson, 
true);]]></script>
-</div></div><p><span style="line-height: 1.5625;">Please note that as of Camel 
2.16 there are five different overloaded <strong><code>json()</code></strong> 
DSL methods which support the <strong><code>prettyPrint</code></strong> option 
in combination with other settings for 
<strong><code>JsonLibrary</code></strong>, 
<strong><code>unmarshalType</code></strong>, 
<strong><code>jsonView</code></strong> etc.&#160;</span></p><h3 
id="JSON-IntegratingJacksonwithCamel'sTypeConverters"><span style="line-height: 
1.5625;">&#160;</span>Integrating Jackson with 
Camel's&#160;TypeConverters</h3><h3 id="JSON-AvailableasofCamel2.17"><span 
style="line-height: 1.5625;">&#160;</span><strong>Available as of Camel 
2.17</strong></h3><p><span style="line-height: 
1.5625;">The&#160;<strong><code>camel-jackson</code></strong> module allows to 
integrate Jackson as a&#160;<a shape="rect" href="type-converter.html">Type 
Converter</a> in the Camel registry. This works in similar ways 
that&#160;<strong><code>camel-
 jaxb</code></strong>&#160;integrates with the type converter as well. 
However&#160;<strong><code>camel-jackson</code></strong> must be explicit 
enabled, which is done by setting some options on 
the&#160;<strong><code>CamelContext</code></strong> properties, as shown 
below:</span></p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[// Enable Jackson JSON type converter.
-getContext().getProperties().put(&quot;CamelJacksonEnableTypeConverter&quot;, 
&quot;true&quot;);
+Invoice invoice = 
exchange.getIn().getBody(Invoice.class);</plain-text-body><p>If there is a 
single <strong><code>ObjectMapper</code></strong> instance available in the 
Camel registry, it will used by the converter to perform the conversion. 
Otherwise the default mapper will be used. &#160;</p><h3 
id="JSON-FormattedJSONmarshalling(pretty-printing)">Formatted JSON marshalling 
(pretty-printing)</h3><p><strong>Available as of Camel 
2.16</strong></p><p>Using the <strong><code>prettyPrint</code></strong> 
option&#160;one can output a well formatted JSON while 
marshaling:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dataFormats&gt;
+  &lt;json id="xstream" prettyPrint="true"/&gt;
+  &lt;json id="jackson" prettyPrint="true" library="Jackson"/&gt;
+  &lt;json id="gson" prettyPrint="true" library="Gson"/&gt;
+&lt;/dataFormats&gt;</plain-text-body><p><span style="line-height: 
1.5625;">And in Java DSL:</span></p><parameter 
ac:name="language">java</parameter><plain-text-body>from("direct:inPretty").marshal().json(true);
+&#160;
+from("direct:inPretty").marshal().json(JsonLibrary.Jackson, true);
+&#160;
+from("direct:inPretty").marshal().json(JsonLibrary.Gson, 
true);</plain-text-body><p><span style="line-height: 1.5625;">Please note that 
as of Camel 2.16 there are five different overloaded 
<strong><code>json()</code></strong> DSL methods which support the 
<strong><code>prettyPrint</code></strong> option in combination with other 
settings for <strong><code>JsonLibrary</code></strong>, 
<strong><code>unmarshalType</code></strong>, 
<strong><code>jsonView</code></strong> etc.&#160;</span></p><h3 
id="JSON-IntegratingJacksonwithCamel'sTypeConverters"><span style="line-height: 
1.5625;">&#160;</span>Integrating Jackson with 
Camel's&#160;TypeConverters</h3><h3 id="JSON-AvailableasofCamel2.17"><span 
style="line-height: 1.5625;">&#160;</span><strong>Available as of Camel 
2.17</strong></h3><p><span style="line-height: 
1.5625;">The&#160;<strong><code>camel-jackson</code></strong> module allows to 
integrate Jackson as a&#160;<a shape="rect" href="type-converter.html">Type 
Converter</a> in the Came
 l registry. This works in similar ways 
that&#160;<strong><code>camel-jaxb</code></strong>&#160;integrates with the 
type converter as well. 
However&#160;<strong><code>camel-jackson</code></strong> must be explicit 
enabled, which is done by setting some options on 
the&#160;<strong><code>CamelContext</code></strong> properties, as shown 
below:</span></p><parameter 
ac:name="language">java</parameter><plain-text-body>// Enable Jackson JSON type 
converter.
+getContext().getProperties().put("CamelJacksonEnableTypeConverter", "true");
 
 // Allow Jackson JSON to convert to pojo types also (by default Jackson only 
converts to String and other simple types).
-getContext().getProperties().put(&quot;CamelJacksonTypeConverterToPojo&quot;, 
&quot;true&quot;);]]></script>
-</div></div><p>The&#160;<strong><code>camel-jackson</code></strong> type 
converter integrates with JAXB which means you can annotate POJO class 
with&#160;JAXB annotations that Jackson can leverage.&#160;</p><h3 
id="JSON-DependenciesforXStream"><span style="line-height: 
1.5625;">Dependencies for XStream</span></h3><p>To use JSON in your camel 
routes you need to add the a dependency 
on&#160;<strong><code>camel-xstream</code></strong> which implements this data 
format.</p><p>If you use maven you could just add the following to your 
<strong><code>pom.xml</code></strong>, substituting the version number for the 
latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+getContext().getProperties().put("CamelJacksonTypeConverterToPojo", 
"true");</plain-text-body><p>The&#160;<strong><code>camel-jackson</code></strong>
 type converter integrates with JAXB which means you can annotate POJO class 
with&#160;JAXB annotations that Jackson can leverage.&#160;</p><h3 
id="JSON-DependenciesforXStream"><span style="line-height: 
1.5625;">Dependencies for XStream</span></h3><p>To use JSON in your camel 
routes you need to add the a dependency 
on&#160;<strong><code>camel-xstream</code></strong> which implements this data 
format.</p><p>If you use maven you could just add the following to your 
<strong><code>pom.xml</code></strong>, substituting the version number for the 
latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-xstream&lt;/artifactId&gt;
   &lt;version&gt;2.9.2&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div><h3 id="JSON-DependenciesforJackson">Dependencies for 
Jackson</h3><p>To use JSON in your camel routes you need to add the a 
dependency on&#160;<strong><code>camel-jackson</code></strong> which implements 
this data format.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+</plain-text-body><h3 id="JSON-DependenciesforJackson">Dependencies for 
Jackson</h3><p>To use JSON in your camel routes you need to add the a 
dependency on&#160;<strong><code>camel-jackson</code></strong> which implements 
this data format.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-jackson&lt;/artifactId&gt;
   &lt;version&gt;2.9.2&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div><h3 id="JSON-DependenciesforGSON">Dependencies for GSON</h3><p>To 
use JSON in your camel routes you need to add the a dependency 
on&#160;<strong><code>camel-gson</code></strong> which implements this data 
format.</p><p>If you use maven you could just add the following to your 
<strong><code>pom.xml</code></strong>, substituting the version number for the 
latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+</plain-text-body><h3 id="JSON-DependenciesforGSON">Dependencies for 
GSON</h3><p>To use JSON in your camel routes you need to add the a dependency 
on&#160;<strong><code>camel-gson</code></strong> which implements this data 
format.</p><p>If you use maven you could just add the following to your 
<strong><code>pom.xml</code></strong>, substituting the version number for the 
latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-gson&lt;/artifactId&gt;
   &lt;version&gt;2.10.0&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div></div>
+</plain-text-body></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/jxpath.html
==============================================================================
--- websites/production/camel/content/jxpath.html (original)
+++ websites/production/camel/content/jxpath.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: JXPath
@@ -92,13 +81,11 @@
 
 <p>You can use XPath expressions directly using smart completion in your IDE 
as follows</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;queue:foo&quot;).filter().
-  jxpath(&quot;/in/body/foo&quot;).
-  to(&quot;queue:bar&quot;)
-]]></script>
-</div></div>
+<plain-text-body>
+from("queue:foo").filter().
+  jxpath("/in/body/foo").
+  to("queue:bar")
+</plain-text-body>
 
 <h3 id="JXPath-Variables">Variables</h3>
 
@@ -115,38 +102,30 @@ from(&quot;queue:foo&quot;).filter().
 
 <p>If you prefer to configure your routes in your <a shape="rect" 
href="spring.html">Spring</a> XML file then you can use JXPath expressions as 
follows</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
-       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
-       xsi:schemaLocation=&quot;
+<parameter ac:name="lang">xml</parameter><plain-text-body>
+&lt;beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
-       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd&quot;&gt;
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
 
-  &lt;camelContext id=&quot;camel&quot; 
xmlns=&quot;http://activemq.apache.org/camel/schema/spring&quot;&gt;
+  &lt;camelContext id="camel" 
xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
     &lt;route&gt;
-      &lt;from uri=&quot;activemq:MyQueue&quot;/&gt;
+      &lt;from uri="activemq:MyQueue"/&gt;
       &lt;filter&gt;
-        &lt;jxpath&gt;in/body/name = &#39;James&#39;&lt;/xpath&gt;
-        &lt;to uri=&quot;mqseries:SomeOtherQueue&quot;/&gt;
+        &lt;jxpath&gt;in/body/name = 'James'&lt;/xpath&gt;
+        &lt;to uri="mqseries:SomeOtherQueue"/&gt;
       &lt;/filter&gt;
     &lt;/route&gt;
   &lt;/camelContext&gt;
 &lt;/beans&gt;
-]]></script>
-</div></div>
+</plain-text-body>
 
 <h3 id="JXPath-Examples">Examples</h3>
 
 <p>Here is a simple <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java";>example</a>
 using a JXPath expression as a predicate in a <a shape="rect" 
href="message-filter.html">Message Filter</a></p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;).
-        filter().jxpath(&quot;in/body/name=&#39;James&#39;&quot;).
-        to(&quot;mock:result&quot;);
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=example|lang=java|url=camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterTest.java}</plain-text-body>
 
 <h2 id="JXPath-JXPathinjection">JXPath injection </h2>
 
@@ -154,17 +133,15 @@ from(&quot;direct:start&quot;).
 
 <p>For example</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
 public class Foo {
        
-    @MessageDriven(uri = &quot;activemq:my.queue&quot;)
-    public void doSomething(@JXPath(&quot;in/body/foo&quot;) String 
correlationID, @Body String body) {
+    @MessageDriven(uri = "activemq:my.queue")
+    public void doSomething(@JXPath("in/body/foo") String correlationID, @Body 
String body) {
                // process the inbound message here
     }
 }
-]]></script>
-</div></div>
+</plain-text-body>
 
 
 <h3 id="JXPath-Loadingscriptfromexternalresource">Loading script from external 
resource</h3>
@@ -172,11 +149,9 @@ public class Foo {
 
 <p>You can externalize the script and have Camel load it from a resource such 
as <code>"classpath:"</code>, <code>"file:"</code>, or <code>"http:"</code>.<br 
clear="none">
 This is done using the following syntax: 
<code>"resource:scheme:location"</code>, eg to refer to a file on the classpath 
you can do:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-.setHeader(&quot;myHeader&quot;).jxpath(&quot;resource:classpath:myjxpath.txt&quot;)
-]]></script>
-</div></div>
+<plain-text-body>
+.setHeader("myHeader").jxpath("resource:classpath:myjxpath.txt")
+</plain-text-body>
 
 
 <h3 id="JXPath-Dependencies">Dependencies</h3>
@@ -185,15 +160,13 @@ This is done using the following syntax:
 
 <p>If you use maven you could just add the following to your pom.xml, 
substituting the version number for the latest &amp; greatest release (see <a 
shape="rect" href="download.html">the download page for the latest 
versions</a>).</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
+<plain-text-body>
 &lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-jxpath&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div>
+</plain-text-body>
 
 <p>Otherwise, you'll also need <a shape="rect" class="external-link" 
href="http://repo2.maven.org/maven2/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar";
 rel="nofollow">Commons JXPath</a>.</p></div>
         </td>


Reply via email to