You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/06/04 08:09:47 UTC
[camel] 02/02: Polished
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7669be515297756642bc55b617603013f350fe6d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jun 4 10:09:28 2022 +0200
Polished
---
.../src/main/docs/jacksonXml-dataformat.adoc | 88 +++++++++++-----------
1 file changed, 45 insertions(+), 43 deletions(-)
diff --git a/components/camel-jacksonxml/src/main/docs/jacksonXml-dataformat.adoc b/components/camel-jacksonxml/src/main/docs/jacksonXml-dataformat.adoc
index a0ec5428cf8..4be9b42e628 100644
--- a/components/camel-jacksonxml/src/main/docs/jacksonXml-dataformat.adoc
+++ b/components/camel-jacksonxml/src/main/docs/jacksonXml-dataformat.adoc
@@ -88,7 +88,7 @@ to XML.
Note that the weight field is missing in the resulting XML:
-[source,java]
+[source,xml]
----------------------------
<pojo age="30" weight="70"/>
----------------------------
@@ -100,8 +100,9 @@ As an example of using this attribute you can instead of:
[source,java]
---------------------------------------------------------------------------------------------------
JacksonXMLDataFormat ageViewFormat = new JacksonXMLDataFormat(TestPojoView.class, Views.Age.class);
-from("direct:inPojoAgeView").
- marshal(ageViewFormat);
+
+from("direct:inPojoAgeView")
+ .marshal(ageViewFormat);
---------------------------------------------------------------------------------------------------
Directly specify your https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonView.java[JSON
@@ -109,18 +110,20 @@ view] inside the Java DSL as:
[source,java]
------------------------------------------------------------
-from("direct:inPojoAgeView").
- marshal().jacksonXml(TestPojoView.class, Views.Age.class);
+from("direct:inPojoAgeView")
+ .marshal().jacksonXml(TestPojoView.class, Views.Age.class);
------------------------------------------------------------
And the same in XML DSL:
[source,xml]
---------------------------------------------------------------------------------------------------------------------------------------------------
+<route>
<from uri="direct:inPojoAgeView"/>
- <marshal>
- <jacksonXml unmarshalType="org.apache.camel.component.jacksonxml.TestPojoView" jsonView="org.apache.camel.component.jacksonxml.Views$Age"/>
- </marshal>
+ <marshal>
+ <jacksonXml unmarshalType="org.apache.camel.component.jacksonxml.TestPojoView" jsonView="org.apache.camel.component.jacksonxml.Views$Age"/>
+ </marshal>
+</route>
---------------------------------------------------------------------------------------------------------------------------------------------------
== Setting serialization include option
@@ -149,7 +152,7 @@ format.setInclude("NON_NULL");
Or from XML DSL you configure this as
-[source,java]
+[source,xml]
------------------------------------------------------
<dataFormats>
<jacksonXml id="jacksonxml" include="NON_NULL"/>
@@ -176,7 +179,7 @@ format.setAllowJmsType(true);
Or from XML DSL you configure this as
-[source,java]
+[source,xml]
-------------------------------------------------------
<dataFormats>
<jacksonXml id="jacksonxml" allowJmsType="true"/>
@@ -203,20 +206,20 @@ format.setUnmarshalType(MyPojo.class);
And if you use XML DSL then you configure to use list
using `useList` attribute as shown below:
-[source,java]
+[source,xml]
--------------------------------------------
- <dataFormats>
- <jacksonXml id="jack" useList="true"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jack" useList="true"/>
+</dataFormats>
--------------------------------------------
And you can specify the pojo type also
-[source,java]
+[source,xml]
-------------------------------------------------------------------------------
- <dataFormats>
- <jacksonXml id="jack" useList="true" unmarshalType="com.foo.MyPojo"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jack" useList="true" unmarshalType="com.foo.MyPojo"/>
+</dataFormats>
-------------------------------------------------------------------------------
== Using custom Jackson modules
@@ -224,11 +227,11 @@ And you can specify the pojo type also
You can use custom Jackson modules by specifying the class names of
those using the moduleClassNames option as shown below.
-[source,java]
+[source,xml]
-----------------------------------------------------------------------------------------------------------------------------------------
- <dataFormats>
- <jacksonXml id="jack" useList="true" unmarshalType="com.foo.MyPojo" moduleClassNames="com.foo.MyModule,com.foo.MyOtherModule"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jack" useList="true" unmarshalType="com.foo.MyPojo" moduleClassNames="com.foo.MyModule,com.foo.MyOtherModule"/>
+</dataFormats>
-----------------------------------------------------------------------------------------------------------------------------------------
When using moduleClassNames then the custom jackson modules are not
@@ -237,19 +240,18 @@ 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:
-[source,java]
+[source,xml]
------------------------------------------------------------------------------------------------------------------
- <bean id="myJacksonModule" class="com.foo.MyModule">
- ... // configure the module as you want
- </bean>
+<bean id="myJacksonModule" class="com.foo.MyModule">
+ ... // configure the module as you want
+</bean>
- <dataFormats>
- <jacksonXml id="jacksonxml" useList="true" unmarshalType="com.foo.MyPojo" moduleRefs="myJacksonModule"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jacksonxml" useList="true" unmarshalType="com.foo.MyPojo" moduleRefs="myJacksonModule"/>
+</dataFormats>
------------------------------------------------------------------------------------------------------------------
- Multiple modules can be specified separated by comma, such as
-moduleRefs="myJacksonModule,myOtherModule"
+Multiple modules can be specified separated by comma, such as `moduleRefs="myJacksonModule,myOtherModule"`.
== Enabling or disable features using Jackson
@@ -257,20 +259,20 @@ 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:
-[source,java]
+[source,xml]
-------------------------------------------------------------------------------------------------------------------
- <dataFormats>
- <jacksonXml id="jacksonxml" unmarshalType="com.foo.MyPojo" disableFeatures="FAIL_ON_UNKNOWN_PROPERTIES"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jacksonxml" unmarshalType="com.foo.MyPojo" disableFeatures="FAIL_ON_UNKNOWN_PROPERTIES"/>
+</dataFormats>
-------------------------------------------------------------------------------------------------------------------
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
+from the following enum classes:
-* com.fasterxml.jackson.databind.SerializationFeature
-* com.fasterxml.jackson.databind.DeserializationFeature
-* com.fasterxml.jackson.databind.MapperFeature
+* `com.fasterxml.jackson.databind.SerializationFeature`
+* `com.fasterxml.jackson.databind.DeserializationFeature`
+* `com.fasterxml.jackson.databind.MapperFeature`
To enable a feature use the enableFeatures options instead.
@@ -310,11 +312,11 @@ Otherwise the default mapper will be used.
Using the `prettyPrint` option one can output a well formatted XML while
marshalling:
-[source,java]
+[source,xml]
------------------------------------------------
- <dataFormats>
- <jacksonXml id="jack" prettyPrint="true"/>
- </dataFormats>
+<dataFormats>
+ <jacksonXml id="jack" prettyPrint="true"/>
+</dataFormats>
------------------------------------------------
And in Java DSL: