camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r917090 [3/3] - in /websites/production/camel/content: book-dataformat-appendix.html book-in-one-page.html cache/main.pageCache json.html
Date Tue, 22 Jul 2014 12:18:34 GMT
Modified: websites/production/camel/content/json.html
==============================================================================
--- websites/production/camel/content/json.html (original)
+++ websites/production/camel/content/json.html Tue Jul 22 12:18:33 2014
@@ -252,7 +252,19 @@ from("direct:inPojoAgeView").
     <json library="Jackson" unmarshalTypeName="org.apache.camel.component.jackson.TestPojoView"
jsonView="org.apache.camel.component.jackson.Views$Age"/>
   </marshal>
 ]]></script>
-</div></div><h3 id="JSON-DependenciesforXStream">Dependencies for XStream</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><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">
+<script class="theme: Default; brush: java; gutter: false" 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">
+<script class="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
   &lt;dataFormats&gt;
+      &lt;json id=&quot;json&quot; library=&quot;Jackson&quot; include=&quot;NOT_NULL&quot;/&gt;
+    &lt;/dataFormats&gt;]]></script>
+</div></div><p>&#160;</p><h3 id="JSON-DependenciesforXStream">Dependencies
for XStream</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">
 <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-xstream&lt;/artifactId&gt;



Mime
View raw message