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 & 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, </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("NON_NULL");]]></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[ <dataFormats> + <json id="json" library="Jackson" include="NOT_NULL"/> + </dataFormats>]]></script> +</div></div><p> </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 & 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[<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-xstream</artifactId>