camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r1006521 [3/3] - in /websites/production/camel/content: book-dataformat-appendix.html book-in-one-page.html cache/main.pageCache json.html xmljson.html
Date Fri, 10 Feb 2017 19:20:09 GMT
Modified: websites/production/camel/content/json.html
==============================================================================
--- websites/production/camel/content/json.html (original)
+++ websites/production/camel/content/json.html Fri Feb 10 19:20:09 2017
@@ -86,39 +86,43 @@
 	<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 XStream 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[// lets turn Object messages into json then send to MQSeries
-from(&quot;activemq:My.Queue&quot;).
-  marshal().json().
-  to(&quot;mqseries:Another.Queue&quot;);
-]]></script>
-</div></div><h3 id="JSON-UsingJSONdataformatwiththeJacksonlibrary">Using JSON data format with the Jackson 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[// lets turn Object messages into json then send to MQSeries
-from(&quot;activemq:My.Queue&quot;).
-  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[// lets turn Object messages into json then send to MQSeries
-from(&quot;activemq:My.Queue&quot;).
-  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>DataFormats</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;
-            &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;/dataFormats&gt;
+<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;)
+  .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;)
+  .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;)
+  .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;
+  &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;/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;
-        &lt;/route&gt;
+<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;
+&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 marshalling 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. First create one or more marker classes.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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 {
 
@@ -126,7 +130,7 @@ public class Views {
     static class Weight { }
 }
 ]]></script>
-</div></div>Use the marker classes with the <code>@JsonView</code> 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">
+</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;
@@ -136,11 +140,11 @@ private int height = 190;
 @JsonView(Views.Weight.class)
 private int weight = 70;
 ]]></script>
-</div></div>Finally use the Camel <code>JacksonDataFormat</code> to marshall the above POJO to JSON.<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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>Note that the height field is missing in the resulting JSON:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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">
@@ -161,20 +165,20 @@ protected static class AgeExclusionStrat
     }
 }
 ]]></script>
-</div></div>The <code>GsonDataFormat</code> accepts an <code>ExclusionStrategy</code> in its constructor:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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 <code>@ExcludeAge</code> when marshalling 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">
+</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;
 }
 ]]></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">
+</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 {
 
     private int id;
@@ -206,38 +210,39 @@ from(&quot;direct:inPojoExcludeAge&quot;
     }
 }
 ]]></script>
-</div></div><p>Then we can configure the <code>org.apache.camel.component.gson.GsonDataFormat</code> in a Spring XML files as shown below. Notice we use <code>fieldNamingPolicy</code> property to set the field mapping. This property is an enum from GSon <code>com.google.gson.FieldNamingPolicy</code> which has a number of pre defined mappings. If you need full control you can use the property <code>FieldNamingStrategy</code> and implement a custom <code>com.google.gson.FieldNamingStrategy</code> 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;
-        &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;!-- 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;/bean&gt;
+</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;
+
+  &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;!-- 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;/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;
-
-        &lt;route&gt;
-            &lt;from uri=&quot;direct:inPojo&quot;/&gt;
-            &lt;marshal ref=&quot;gson&quot;/&gt;
-        &lt;/route&gt;
-
-        &lt;route&gt;
-            &lt;from uri=&quot;direct:backPojo&quot;/&gt;
-            &lt;unmarshal ref=&quot;gson&quot;/&gt;
-        &lt;/route&gt;
-
-    &lt;/camelContext&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
+  &lt;route&gt;
+    &lt;from uri=&quot;direct:inPojo&quot;/&gt;
+    &lt;marshal ref=&quot;gson&quot;/&gt;
+  &lt;/route&gt;
+
+  &lt;route&gt;
+    &lt;from uri=&quot;direct:backPojo&quot;/&gt;
+    &lt;unmarshal ref=&quot;gson&quot;/&gt;
+  &lt;/route&gt;
+&lt;/camelContext&gt;
 ]]></script>
-</div></div><h3 id="JSON-Include/ExcludefieldsusingthejsonViewattributewithJacksonDataFormat">Include/Exclude fields using the <code>jsonView</code> 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">
+</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);
-from(&quot;direct:inPojoAgeView&quot;).
-  marshal(ageViewFormat);
+
+from(&quot;direct:inPojoAgeView&quot;)
+  .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;).
-  marshal().json(TestPojoView.class, Views.Age.class);
+<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><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;
@@ -245,103 +250,105 @@ from(&quot;direct:inPojoAgeView&quot;).
     &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;/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 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">
+</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)
 public class MyPojo {
-   ...
+   // ...
 }]]></script>
-</div></div><p>But this requires you to include that annotation in your pojo source code. You can also configure the Camel JsonDataFormat to set the include option, as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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: java; 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-UnmarshallingfromjsontoPOJOwithdynamicclassname">Unmarshalling 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.<br clear="none"><span style="line-height: 1.4285715;">The header has key </span><code style="line-height: 1.4285715;">CamelJacksonUnmarshalType</code><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 Camel 2.14 onwards.&#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 JMSType header from the JMS spec that indicates that also. To enable support for JMSType you would need to turn that on, on the jacks
 on data format as shown:</span></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: java; 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-UnmarshallingfromjsontoList&lt;Map&gt;orList&lt;pojo&gt;">Unmarshalling from json to List&lt;Map&gt; or List&lt;pojo&gt;</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;<code>useList="true"</code> or use the&#160;<code>org.apache.camel.component.jackson.ListJacksonDataFormat</code>. 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: 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();
 // 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: java; 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>
+<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: java; 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-UsingcustomJacksonObjectMapper">Using custom Jackson ObjectMapper</h3><p><strong>Available as of Camel 2.17</strong></p><p>You can use custom Jackson ObjectMapper 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: java; 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 myMapper 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 moduleClassNames 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[    &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;moduleClassNames 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 modulesRefs 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: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;myJacksonModule&quot; class=&quot;com.foo.MyModule&quot;&gt;
-      ... // configure the module as you want
-    &lt;/bean&gt;
+<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;
+  ... // configure the module as you want
+&lt;/bean&gt;
  
-    &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 moduleRefs="myJacksonModule,myOtherModule"</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 ObjectMapper uses. For example to disable failing on unknown properties when marshalling, you can configure this using the disableFeatures:</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[ &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>com.fasterxml.jackson.databind.SerializationFeature</li><li>com.fasterxml.jackson.databind.DeserializationFeature</li><li>com.fasterxml.jackson.databind.MapperFeature</li></ul><p>To enable a feature use the enableFeatures options instead.</p><p>From Java code you can use the type safe methods from camel-jackson module:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+&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);
 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 <code>ObjectMapper</code> can be used to convert maps to POJO objects. Jackson component comes with the data converter that can be used to convert <code>java.util.Map</code> 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">
+</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);
 ...
 // Later in the processor
 Invoice invoice = exchange.getIn().getBody(Invoice.class);]]></script>
-</div></div><p>If there is a single <code>ObjectMapper</code> 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 <code>prettyPrint</code> option&#160;one can output a well formatted JSON while marshalling:</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[ &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>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&#8217;re 5 different overloaded <code>json()</code> DSL methods which support the <code>prettyPrint</code> option in combination with other settings for <code>JsonLibrary</code>, <code>unmarshalType</code>, <code>jsonView</code> etc.&#160;</span></p><h3 id="JSON-"><span style="line-height: 1.5625;">&#160;</span></h3><h3 id="JSON-IntegratingJacksonwithCamel'sTypeConverters">Integrating Jackson with Camel's&#160;TypeConverters</h3><h3 id="JSON-.1"><span style="line-height: 1.5625;">&#160;</span></h3><p><strong>Available as of Camel 2.17</strong></p><p><span style="line-height: 1.5625;">The&#160;<code>camel-jackson</code> 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;<code>camel-jaxb</code>&#160;integrates with the type converter as well. However&#160;<code>camel-jackson</code> 
 must be explicit enabled, which is done by setting some options on the&#160;<code>CamelContext</code> 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
+</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;);
-// allow Jackson json to convert to pojo types also (by default jackson only converts to String and other simple types)
+
+// 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;<code>camel-jackson</code> type converter integrates with JAXB which means you can annotate POJO class with&#160;JAXB annotations that Jackson can leverage.&#160;</p><p><span style="line-height: 1.5625;"><br clear="none"></span></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 <strong>camel-xstream</strong> which implements this data format.</p><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">
+</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;
   &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 <strong>camel-jackson</strong> which implements this data format.</p><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">
+</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;
   &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 <strong>camel-gson</strong> which implements this data format.</p><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">
+</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;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-gson&lt;/artifactId&gt;

Modified: websites/production/camel/content/xmljson.html
==============================================================================
--- websites/production/camel/content/xmljson.html (original)
+++ websites/production/camel/content/xmljson.html Fri Feb 10 19:20:09 2017
@@ -87,8 +87,8 @@
         <tr>
         <td valign="top" width="100%">
 <div class="wiki-content maincontent"><h2 id="XmlJson-XMLJSONDataFormat(camel-xmljson)">XML JSON Data Format (camel-xmljson)</h2><p><strong>Available as of Camel 2.10</strong></p><p>Camel already supports a number of data formats to perform XML and JSON-related conversions, but all of them require a POJO either as an input (for marshalling) or produce a POJO as output (for unmarshalling). This data format provides the capability to convert from XML to JSON and viceversa directly, without stepping through intermediate POJOs.</p><p>This data format leverages the <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/" rel="nofollow">Json-lib</a> library to achieve direct conversion. In this context, XML is considered the high-level format, while JSON is the low-level format. Hence, the marshal/unmarshal semantics are assigned as follows:</p><ul><li>marshalling =&gt; converting from XML to JSON</li><li>unmarshalling =&gt; converting from JSON to XML.</li></ul><h3 i
 d="XmlJson-Options">Options</h3><p>This data format supports the following options. You can set them via all DSLs. The defaults marked with&#160;<strong><code>(*)</code></strong> are determined by <strong><code>json-lib</code></strong>, rather than the code of the data format itself. They are reproduced here for convenience to avoid having to consult the <strong><code>json-lib</code></strong> documentation directly.</p><div class="confluenceTableSmall"><div class="table-wrap">
- <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>UTF-8 (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span> <strong>(JSON to XML conversion).</strong></p><p>Sets the encoding for the call to <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/apidocs/net/sf/json/xml/XMLSerializer.html#write(net.sf.json.JSON, java.lang.String)" rel="nofollow"><code>XMLSeriali
 zer.write()</code></a> method, hence it is only used when producing XML. <br clear="none" class="atl-forced-newline"> However, when producing JSON, the encoding is determined by the input String being processed.</p><p>If the conversion is performed on an <strong><code>InputStream</code></strong>,&#160;<strong><code>json-lib</code></strong> uses the platform's default encoding, e.g., determined by the <strong><code>file.encoding</code></strong> system property.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>elementName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>'e' (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Specifies the name of the XML elements representing each array 
 element.</p><p>See <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/snippets.html#JSONObject_to_XML_change_node_names" rel="nofollow">json-lib doc</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>arrayName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>'a' (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Specifies the name of the top-level XML element.</p><p>For example, when converting:</p><p><strong><code>[1, 2, 3]</code></strong></p><p>it is, by default, translated as:</p><p><strong><code>&lt;a&gt;&lt;e&gt;1&lt;/e&gt;&lt;e&gt;2&lt;/e&gt;&lt;e&gt;3&lt;/e&gt;&lt;/a&gt;</code></strong></p><p>By setting this option or <strong><code>rootName</code></s
 trong>, you can alter the name of the element <strong><code>a</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>rootName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>When converting any JSON construct (<strong><code>object</code>, <code>array</code>, <code>null</code></strong>) to XML (unmarshalling), this option specifies the name of the top-level XML element.</p><p>If not set,&#160;<strong><code>json-lib</code></strong> will use <strong><code>arrayName</code></strong> or&#160;<strong><code>objectName</code></strong> (default value: <strong><code>o</code></strong>, at the current time it is not configurable i
 n this data format).</p><p>If set to <strong><code>root</code></strong>, the JSON string:</p><p><strong><code>{ "x": "value1", "y" : "value2" }</code></strong>&#160;</p><p>is translated as:</p><p><strong><code>&lt;root&gt;&lt;x&gt;value1&lt;/x&gt;&lt;y&gt;value2&lt;/y&gt;&lt;/root&gt;</code></strong></p><p>otherwise the&#160;<strong><code>root</code></strong> element would be named <strong><code>o</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>namespaceLenient</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>According to the <strong>json-lib</strong> docs: "<em>Flag to be tolerant to incomplete namespace pref
 ixes.</em>"</p><p>In most cases, j<strong>son-lib</strong> automatically changes this flag at runtime to match the processing.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>namespaceMappings</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>List&lt;NamespacesPerElementMapping&gt;</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Binds namespace prefixes and URIs to specific JSON elements.&#160;</p><p><strong><code>NamespacesPerElementMapping</code></strong> is a wrapper around an element name + a Map of prefixes against URIs.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>expandableProperties</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><
 code>List&lt;String&gt;</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>With expandable properties, JSON array elements are converted to XML as a sequence of repetitive XML elements with the local name equal to the JSON key.</p><p>For example, the following JSON:&#160;</p><p><strong><code>{ number: 1,2,3 }</code></strong></p><p>is normally translated as:</p><p><strong><code>&lt;number&gt;&lt;e&gt;1&lt;/e&gt;&lt;e&gt;2&lt;/e&gt;&lt;e&gt;3&lt;/e&gt;&lt;/number&gt;</code></strong></p><p>where&#160;<strong><code>e</code></strong> can be modified by setting&#160;<strong><code>elementName</code></strong>.</p><p>However, if&#160;<strong><code>number</code></strong> is set as an expandable property, it's translated as:</p><p><strong><code>&lt;n
 umber&gt;1&lt;/number&gt;&lt;number&gt;2&lt;/number&gt;&lt;number&gt;3&lt;/number&gt;</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>typeHints</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>TypeHintsEnum</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>YES</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Adds type hints to the resulting XML to aid conversion back to JSON.&#160;See documentation <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/apidocs/net/sf/json/xml/XMLSerializer.html" rel="nofollow">here</a> for an explanation.</p><p><strong><code>TypeHintsEnum</code></strong> comprises the following values, which lead to different combinations of the underlying XMLSerializer's <strong><code>ty
 peHintsEnabled</code></strong> and <strong><code>typeHintsCompatibility</code></strong> flags:</p>
-     <ul><li><code>TypeHintsEnum.NO</code>&#160;<strong><code>=&gt;</code></strong> <code>typeHintsEnabled</code>&#160;=&#160;<code>false</code></li><li><code>TypeHintsEnum.YES</code>&#160;<strong><code>=&gt;</code></strong>&#160; <code>typeHintsEnabled</code> = <code>true</code>,&#160;&#160;<code>typeHintsCompatibility</code> =&#160;<code>true</code></li><li><code>TypeHintsEnum.WITH_PREFIX</code>&#160;<strong><code>=&gt;</code></strong>&#160; <code>typeHintsEnabled</code> = <code>true</code>,&#160;&#160;<code>typeHintsCompatibility</code> = <code>false</code></li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>forceTopLevelObject</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span
 > <strong>(XML to JSON conversion).</strong></p><p>Determines whether the resulting JSON will start off with a top-most element whose name matches the XML root element.</p><p>If this option is <strong><code>false</code></strong>, the XML string:</p><p><strong><code>&lt;a&gt;&lt;x&gt;1&lt;/x&gt;&lt;y&gt;2&lt;/y&gt;&lt;/a&gt;</code></strong></p><p>is translated as:</p><p><strong><code>{'x: '1', 'y': '2'}</code></strong></p><p>If&#160;<strong><code>true</code></strong>, it's translated as:</p><p><strong><code>{ 'a':&#160; { 'x: '1', 'y': '2' }}</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>skipWhitespace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160
 ;(XML to JSON conversion).</strong></p><p>Determines whether white spaces between XML elements will be regarded as text values or disregarded.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>trimSpaces</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Determines whether leading and trailing white spaces will be omitted from String values.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>skipNamespaces</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="
 1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Signals whether namespaces should be ignored. By default they will be added to the JSON output using&#160;<strong><code>@xmlns</code></strong> elements.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>removeNamespacePrefixes</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Removes the namespace prefixes from XML qualified elements, so that the resulting JSON string does not contain them.</p></td></tr></tbody></table>
+ <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>UTF-8 (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span> <strong>(JSON to XML conversion).</strong></p><p>Sets the encoding for the call to <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/apidocs/net/sf/json/xml/XMLSerializer.html#write(net.sf.json.JSON, java.lang.String)" rel="nofollow"><code>XMLSeriali
 zer.write()</code></a> method, hence it is only used when producing XML. <br clear="none" class="atl-forced-newline"> However, when producing JSON, the encoding is determined by the input String being processed.</p><p>If the conversion is performed on an <strong><code>InputStream</code></strong>,&#160;<strong><code>json-lib</code></strong> uses the platform's default encoding, e.g., determined by the <strong><code>file.encoding</code></strong> system property.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>elementName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>'e' (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Specifies the name of the XML elements representing each array 
 element.</p><p>See <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/snippets.html#JSONObject_to_XML_change_node_names" rel="nofollow">json-lib doc</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>arrayName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>'a' (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Specifies the name of the top-level XML element.</p><p>For example, when converting:</p><p><strong><code>[1, 2, 3]</code></strong></p><p>it is, by default, translated as:</p><p><strong><code>&lt;a&gt;&lt;e&gt;1&lt;/e&gt;&lt;e&gt;2&lt;/e&gt;&lt;e&gt;3&lt;/e&gt;&lt;/a&gt;</code></strong></p><p>By setting this option or <strong><code>rootName</code></s
 trong>, you can alter the name of the element <strong><code>a</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>rootName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>When converting any JSON construct (<strong><code>object</code>, <code>array</code>, <code>null</code></strong>) to XML (unmarshalling), this option specifies the name of the top-level XML element.</p><p>If not set,&#160;<strong><code>json-lib</code></strong> will use <strong><code>arrayName</code></strong> or&#160;<strong><code>objectName</code></strong> (default value: <strong><code>o</code></strong>, at the current time it is not configurable i
 n this data format).</p><p>If set to <strong><code>root</code></strong>, the JSON string:</p><p><strong><code>{ "x": "value1", "y" : "value2" }</code></strong>&#160;</p><p>is translated as:</p><p><strong><code>&lt;root&gt;&lt;x&gt;value1&lt;/x&gt;&lt;y&gt;value2&lt;/y&gt;&lt;/root&gt;</code></strong></p><p>otherwise the&#160;<strong><code>root</code></strong> element would be named <strong><code>o</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>namespaceLenient</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>According to the <strong><strong><code>json-lib</code></strong></strong> docs: "<em>Flag to be toleran
 t to incomplete namespace prefixes.</em>"</p><p>In most cases, <strong><strong><code>json-lib</code></strong></strong> automatically changes this flag at runtime to match the processing.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>namespaceMappings</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>List&lt;NamespacesPerElementMapping&gt;</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Binds namespace prefixes and URIs to specific JSON elements.&#160;</p><p><strong><code>NamespacesPerElementMapping</code></strong> is a wrapper around an element name + a map of prefixes against URIs.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>expandableProperties</code></
 p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>List&lt;String&gt;</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>none</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>With expandable properties, JSON array elements are converted to XML as a sequence of repetitive XML elements with the local name equal to the JSON key.</p><p>For example, the following JSON:&#160;</p><p><strong><code>{ "number": 1,2,3 }</code></strong></p><p>is normally translated as:</p><p><strong><code>&lt;number&gt;&lt;e&gt;1&lt;/e&gt;&lt;e&gt;2&lt;/e&gt;&lt;e&gt;3&lt;/e&gt;&lt;/number&gt;</code></strong></p><p>where&#160;<strong><code>e</code></strong> can be modified by setting&#160;<strong><code>elementName</code></strong>.</p><p>However, if&#160;<strong><code>number</code></strong> is set as an expa
 ndable property, it's translated as:</p><p><strong><code>&lt;number&gt;1&lt;/number&gt;&lt;number&gt;2&lt;/number&gt;&lt;number&gt;3&lt;/number&gt;</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>typeHints</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>TypeHintsEnum</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>YES</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(0,128,0);"><strong>unmarshalling</strong></span><strong>&#160;(JSON to XML conversion).</strong></p><p>Adds type hints to the resulting XML to aid conversion back to JSON.&#160;See documentation <a shape="rect" class="external-link" href="http://json-lib.sourceforge.net/apidocs/net/sf/json/xml/XMLSerializer.html" rel="nofollow">here</a> for an explanation.</p><p><strong><code>TypeHintsEnum</code></strong> comprises the following values, which lead to different c
 ombinations of the underlying XMLSerializer's <strong><code>typeHintsEnabled</code></strong> and <strong><code>typeHintsCompatibility</code></strong> flags:</p>
+     <ul><li><p><code>TypeHintsEnum.NO</code>&#160;<strong><code>=&gt;</code></strong> <code>typeHintsEnabled</code>&#160;=&#160;<code>false</code></p></li><li><p><code>TypeHintsEnum.YES</code>&#160;<strong><code>=&gt;</code></strong>&#160; <code>typeHintsEnabled</code> = <code>true</code>,&#160;&#160;<code>typeHintsCompatibility</code> =&#160;<code>true</code></p></li><li><p><code>TypeHintsEnum.WITH_PREFIX</code>&#160;<strong><code>=&gt;</code></strong>&#160; <code>typeHintsEnabled</code> = <code>true</code>,&#160;&#160;<code>typeHintsCompatibility</code> = <code>false</code></p></li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>forceTopLevelObject</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marsh
 alling</strong></span> <strong>(XML to JSON conversion).</strong></p><p>Determines whether the resulting JSON will start off with a top-most element whose name matches the XML root element.</p><p>If this option is <strong><code>false</code></strong>, the XML string:</p><p><strong><code>&lt;a&gt;&lt;x&gt;1&lt;/x&gt;&lt;y&gt;2&lt;/y&gt;&lt;/a&gt;</code></strong></p><p>is translated as:</p><p><strong><code>{"x": "1", "y": "2"}</code></strong></p><p>If&#160;<strong><code>true</code></strong>, it's translated as:</p><p><strong><code>{ "a":&#160; { "x": "1", "y": "2" }}</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>skipWhitespace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</stro
 ng></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Determines whether white spaces between XML elements will be regarded as text values or disregarded.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>trimSpaces</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Determines whether leading and trailing white spaces will be omitted from String values.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>skipNamespaces</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><t
 d colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Signals whether namespaces should be ignored. By default they will be added to the JSON output using&#160;<strong><code>@xmlns</code></strong> elements.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>removeNamespacePrefixes</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false (*)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Used when</strong> <span style="color: rgb(51,51,153);"><strong>marshalling</strong></span><strong>&#160;(XML to JSON conversion).</strong></p><p>Removes the namespace prefixes from XML qualified elements, so that the resulting JSON string does not contain them.</p></td></tr></tbody></table>
 </div></div><h3 id="XmlJson-BasicUsageWiththeJavaDSL">Basic Usage With the Java DSL</h3><h4 id="XmlJson-ExplicitlyInstantiatingtheDataFormat">Explicitly Instantiating the DataFormat</h4><p>Just instantiate the&#160;<strong><code>XmlJsonDataFormat</code></strong> from package <strong><code>org.apache.camel.dataformat.xmljson</code></strong>. Make sure you have installed the <strong><code>camel-xmljson</code></strong> feature (if running on OSGi) or that you've included&#160;<strong><code>camel-xmljson-{version}.jar</code></strong> and its transitive dependencies in your classpath.</p><p>Example, initialization with a default configuration:</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[XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
 ]]></script>



Mime
View raw message