Chapter 142. XJ Since Camel 3.0 Only producer is supported The XJ component allows you to convert XML and JSON documents directly forth and back without the need of intermediate java objects. You can even specify an XSLT stylesheet to convert directly to the target JSON / XML (domain) model. 142.1. Dependencies When using xj with Red Hat build of Camel Spring Boot make sure to use the following Maven dependency to have support for auto configuration: <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-xj-starter</artifactId> </dependency> 142.2. URI format Note The XJ component extends the XSLT component and therefore it supports all options provided by the XSLT component as well. At least look at the XSLT component documentation how to configure the xsl template. The transformDirection option is mandatory and must be either XML2JSON or JSON2XML. The templateName parameter allows to use identify transforma by specifying the name identity . 142.3. Configuring Options Camel components are configured on two separate levels: component level endpoint level 142.3.1. Configuring component options The component level is the highest level which holds general and common configurations that are inherited by the endpoints. For example a component may have security settings, credentials for authentication, urls for network connection and so forth. Some components only have a few options, and others may have many. Because components typically have pre configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all. Configuring components can be done with the Component DSL , in a configuration file (application.properties|yaml), or directly with Java code. 142.3.2. Configuring endpoint options Where you find yourself configuring the most is on endpoints, as endpoints often have many options, which allows you to configure what you need the endpoint to do. The options are also categorized into whether the endpoint is used as consumer (from) or as a producer (to), or used for both. Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java. A good practice when configuring options is to use Property Placeholders , which allows to not hardcode urls, port numbers, sensitive information, and other settings. In other words placeholders allows to externalize the configuration from your code, and gives more flexibility and reuse. The following two sections lists all the options, firstly for the component followed by the endpoint. 142.4. Component Options The XJ component supports 11 options, which are listed below. Name Description Default Type contentCache (producer) Cache for the resource content (the stylesheet file) when it is loaded. If set to false Camel will reload the stylesheet file on each message processing. This is good for development. A cached stylesheet can be forced to reload at runtime via JMX using the clearCachedStylesheet operation. true boolean lazyStartProducer (producer) Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. false boolean autowiredEnabled (advanced) Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. true boolean saxonConfiguration (advanced) To use a custom Saxon configuration. Configuration saxonConfigurationProperties (advanced) To set custom Saxon configuration properties. Map saxonExtensionFunctions (advanced) Allows you to use a custom net.sf.saxon.lib.ExtensionFunctionDefinition. You would need to add camel-saxon to the classpath. The function is looked up in the registry, where you can use commas to separate multiple values to lookup. String secureProcessing (advanced) Feature for XML secure processing (see javax.xml.XMLConstants). This is enabled by default. However, when using Saxon Professional you may need to turn this off to allow Saxon to be able to use Java extension functions. true boolean transformerFactoryClass (advanced) To use a custom XSLT transformer factory, specified as a FQN class name. String transformerFactoryConfigurationStrategy (advanced) A configuration strategy to apply on freshly created instances of TransformerFactory. TransformerFactoryConfigurationStrategy uriResolver (advanced) To use a custom UriResolver. Should not be used together with the option 'uriResolverFactory'. URIResolver uriResolverFactory (advanced) To use a custom UriResolver which depends on a dynamic endpoint resource URI. Should not be used together with the option 'uriResolver'. XsltUriResolverFactory 142.5. Endpoint Options The XJ endpoint is configured using URI syntax: with the following path and query parameters: 142.5.1. Path Parameters (1 parameters) Name Description Default Type resourceUri (producer) Required Path to the template. The following is supported by the default URIResolver. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod. String 142.5.2. Query Parameters (19 parameters) Name Description Default Type allowStAX (producer) Whether to allow using StAX as the javax.xml.transform.Source. You can enable this if the XSLT library supports StAX such as the Saxon library (camel-saxon). The Xalan library (default in JVM) does not support StAXSource. true boolean contentCache (producer) Cache for the resource content (the stylesheet file) when it is loaded. If set to false Camel will reload the stylesheet file on each message processing. This is good for development. A cached stylesheet can be forced to reload at runtime via JMX using the clearCachedStylesheet operation. true boolean deleteOutputFile (producer) If you have output=file then this option dictates whether or not the output file should be deleted when the Exchange is done processing. For example suppose the output file is a temporary file, then it can be a good idea to delete it after use. false boolean failOnNullBody (producer) Whether or not to throw an exception if the input body is null. true boolean output (producer) Option to specify which output type to use. Possible values are: string, bytes, DOM, file. The first three options are all in memory based, where as file is streamed directly to a java.io.File. For file you must specify the filename in the IN header with the key XsltConstants.XSLT_FILE_NAME which is also CamelXsltFileName. Also any paths leading to the filename must be created beforehand, otherwise an exception is thrown at runtime. Enum values: string bytes DOM file string XsltOutput transformDirection (producer) Required Transform direction. Either XML2JSON or JSON2XML. Enum values: XML2JSON JSON2XML TransformDirection transformerCacheSize (producer) The number of javax.xml.transform.Transformer object that are cached for reuse to avoid calls to Template.newTransformer(). 0 int lazyStartProducer (producer (advanced)) Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. false boolean entityResolver (advanced) To use a custom org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource. EntityResolver errorListener (advanced) Allows to configure to use a custom javax.xml.transform.ErrorListener. Beware when doing this then the default error listener which captures any errors or fatal errors and store information on the Exchange as properties is not in use. So only use this option for special use-cases. ErrorListener resultHandlerFactory (advanced) Allows you to use a custom org.apache.camel.builder.xml.ResultHandlerFactory which is capable of using custom org.apache.camel.builder.xml.ResultHandler types. ResultHandlerFactory saxonConfiguration (advanced) To use a custom Saxon configuration. Configuration saxonExtensionFunctions (advanced) Allows you to use a custom net.sf.saxon.lib.ExtensionFunctionDefinition. You would need to add camel-saxon to the classpath. The function is looked up in the registry, where you can comma to separate multiple values to lookup. String secureProcessing (advanced) Feature for XML secure processing (see javax.xml.XMLConstants). This is enabled by default. However, when using Saxon Professional you may need to turn this off to allow Saxon to be able to use Java extension functions. true boolean transformerFactory (advanced) To use a custom XSLT transformer factory. TransformerFactory transformerFactoryClass (advanced) To use a custom XSLT transformer factory, specified as a FQN class name. String transformerFactoryConfigurationStrategy (advanced) A configuration strategy to apply on freshly created instances of TransformerFactory. TransformerFactoryConfigurationStrategy uriResolver (advanced) To use a custom javax.xml.transform.URIResolver. URIResolver xsltMessageLogger (advanced) A consumer to messages generated during XSLT transformations. XsltMessageLogger 142.6. Message Headers The XJ component supports 1 message header(s), which is/are listed below: Name Description Default Type CamelXsltFileName (producer) Constant: XSLT_FILE_NAME The XSLT file name. String 142.7. Using XJ endpoints 142.7.1. Converting JSON to XML The following route does an "identity" transform of the message because no xslt stylesheet is given. In the context of xml to xml transformations, "Identity" transform means that the output document is just a copy of the input document. In case of XJ it means it transforms the json document to an equivalent xml representation. from("direct:start"). to("xj:identity?transformDirection=JSON2XML"); Sample: The input: { "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } } will output <?xml version="1.0" encoding="UTF-8"?> <object xmlns:xj="http://camel.apache.org/component/xj" xj:type="object"> <object xj:name="firstname" xj:type="string">camel</object> <object xj:name="lastname" xj:type="string">apache</object> <object xj:name="personalnumber" xj:type="int">42</object> <object xj:name="active" xj:type="boolean">true</object> <object xj:name="ranking" xj:type="float">3.1415926</object> <object xj:name="roles" xj:type="array"> <object xj:type="string">a</object> <object xj:type="object"> <object xj:name="x" xj:type="null">null</object> </object> </object> <object xj:name="state" xj:type="object"> <object xj:name="needsWater" xj:type="boolean">true</object> </object> </object> As can be seen in the output above, XJ writes some metadata in the resulting xml that can be used in further processing: XJ metadata nodes are always in the http://camel.apache.org/component/xj namespace. JSON key names are placed in the xj:name attribute. The parsed JSON type can be found in the xj:type attribute. The above example already contains all possible types. Generated XML elements are always named "object". Now we can apply a stylesheet, for example: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xj="http://camel.apache.org/component/xj" exclude-result-prefixes="xj"> <xsl:output omit-xml-declaration="no" encoding="UTF-8" method="xml" indent="yes"/> <xsl:template match="/"> <person> <xsl:apply-templates select="//object"/> </person> </xsl:template> <xsl:template match="object[@xj:type != 'object' and @xj:type != 'array' and string-length(@xj:name) > 0]"> <xsl:variable name="name" select="@xj:name"/> <xsl:element name="{USDname}"> <xsl:value-of select="text()"/> </xsl:element> </xsl:template> <xsl:template match="@*|node()"/> </xsl:stylesheet> to the above sample by specifying the template on the endpoint: from("direct:start"). to("xj:com/example/json2xml.xsl?transformDirection=JSON2XML"); and get the following output: <?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber>42</personalnumber> <active>true</active> <ranking>3.1415926</ranking> <x>null</x> <needsWater>true</needsWater> </person> 142.7.2. Converting XML to JSON Based on the explanations above an "identity" transform will be performed when no stylesheet is given: from("direct:start"). to("xj:identity?transformDirection=XML2JSON"); Given the sample input <?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber>42</personalnumber> <active>true</active> <ranking>3.1415926</ranking> <roles> <entry>a</entry> <entry> <x>null</x> </entry> </roles> <state> <needsWater>true</needsWater> </state> </person> will result in { "firstname": "camel", "lastname": "apache", "personalnumber": "42", "active": "true", "ranking": "3.1415926", "roles": [ "a", { "x": "null" } ], "state": { "needsWater": "true" } } You may have noted that the input xml and output json is very similar to the examples above when converting from json to xml altough nothing special is done here. We only transformed an arbitrary XML document to json. XJ uses the following rules by default: The XML root element can be named somehow, it will always end in a json root object declaration '\{}' The json key name is the name of the xml element If there is an name clash as in "<roles>" above where two "<entry>" elements exists a json array will be generated. XML elements with text-only-child-nodes will result in the usual key/string-value pair. Mixed content elements results in key/child-object pair as seen in "<state>" above. Now we can apply again a stylesheet, for example: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xj="http://camel.apache.org/component/xj" exclude-result-prefixes="xj"> <xsl:output omit-xml-declaration="no" encoding="UTF-8" method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="personalnumber"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'int'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="active|needsWater"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'boolean'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="ranking"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'float'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="roles"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'array'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="*[normalize-space(text()) = 'null']"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'null'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> to the sample above by specifying the template on the endpoint: from("direct:start"). to("xj:com/example/xml2json.xsl?transformDirection=XML2JSON"); and get the following output: { "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } } Note, this transformation resulted in exactly the same json document as we used as input to the json2xml convertion. The following XML document is that what is passed to XJ after xsl transformation: <?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber xmlns:xj="http://camel.apache.org/component/xj" xj:type="int">42</personalnumber> <active xmlns:xj="http://camel.apache.org/component/xj" xj:type="boolean">true</active> <ranking xmlns:xj="http://camel.apache.org/component/xj" xj:type="float">3.1415926</ranking> <roles xmlns:xj="http://camel.apache.org/component/xj" xj:type="array"> <entry>a</entry> <entry> <x xj:type="null">null</x> </entry> </roles> <state> <needsWater xmlns:xj="http://camel.apache.org/component/xj" xj:type="boolean">true</needsWater> </state> </person> In the stylesheet we just provided the minimal required type hints to get the same result. The supported type hints are exactly the same as XJ writes to a XML document when converting from json to xml. In the end that means that we can feed back in the result document from the json to xml transformation sample above: <?xml version="1.0" encoding="UTF-8"?> <object xmlns:xj="http://camel.apache.org/component/xj" xj:type="object"> <object xj:name="firstname" xj:type="string">camel</object> <object xj:name="lastname" xj:type="string">apache</object> <object xj:name="personalnumber" xj:type="int">42</object> <object xj:name="active" xj:type="boolean">true</object> <object xj:name="ranking" xj:type="float">3.1415926</object> <object xj:name="roles" xj:type="array"> <object xj:type="string">a</object> <object xj:type="object"> <object xj:name="x" xj:type="null">null</object> </object> </object> <object xj:name="state" xj:type="object"> <object xj:name="needsWater" xj:type="boolean">true</object> </object> </object> and get the same output again: { "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } } As seen in the example above: * xj:type lets you specify exactly the desired output type * xj:name lets you overrule the json key name. This is required when you want to generate key names which contains chars that aren't allowed in XML element names. 142.7.2.1. Available type hints @xj:type= Description object Generate a json object array Generate a json array string Generate a json string int Generate a json number without fractional part float Generate a json number with fractional part boolean Generate a json boolean null Generate an empty value, using the word null 142.8. Spring Boot Auto-Configuration The component supports 12 options, which are listed below. Name Description Default Type camel.component.xj.autowired-enabled Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. true Boolean camel.component.xj.content-cache Cache for the resource content (the stylesheet file) when it is loaded. If set to false Camel will reload the stylesheet file on each message processing. This is good for development. A cached stylesheet can be forced to reload at runtime via JMX using the clearCachedStylesheet operation. true Boolean camel.component.xj.enabled Whether to enable auto configuration of the xj component. This is enabled by default. Boolean camel.component.xj.lazy-start-producer Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. false Boolean camel.component.xj.saxon-configuration To use a custom Saxon configuration. The option is a net.sf.saxon.Configuration type. Configuration camel.component.xj.saxon-configuration-properties To set custom Saxon configuration properties. Map camel.component.xj.saxon-extension-functions Allows you to use a custom net.sf.saxon.lib.ExtensionFunctionDefinition. You would need to add camel-saxon to the classpath. The function is looked up in the registry, where you can use commas to separate multiple values to lookup. String camel.component.xj.secure-processing Feature for XML secure processing (see javax.xml.XMLConstants). This is enabled by default. However, when using Saxon Professional you may need to turn this off to allow Saxon to be able to use Java extension functions. true Boolean camel.component.xj.transformer-factory-class To use a custom XSLT transformer factory, specified as a FQN class name. String camel.component.xj.transformer-factory-configuration-strategy A configuration strategy to apply on freshly created instances of TransformerFactory. The option is a org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy type. TransformerFactoryConfigurationStrategy camel.component.xj.uri-resolver To use a custom UriResolver. Should not be used together with the option 'uriResolverFactory'. The option is a javax.xml.transform.URIResolver type. URIResolver camel.component.xj.uri-resolver-factory To use a custom UriResolver which depends on a dynamic endpoint resource URI. Should not be used together with the option 'uriResolver'. The option is a org.apache.camel.component.xslt.XsltUriResolverFactory type. XsltUriResolverFactory

Commands:
<dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-xj-starter</artifactId> </dependency>
xj:templateName?transformDirection=XML2JSON|JSON2XML[&options]
xj:resourceUri
from("direct:start"). to("xj:identity?transformDirection=JSON2XML");
{ "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } }
<?xml version="1.0" encoding="UTF-8"?> <object xmlns:xj="http://camel.apache.org/component/xj" xj:type="object"> <object xj:name="firstname" xj:type="string">camel</object> <object xj:name="lastname" xj:type="string">apache</object> <object xj:name="personalnumber" xj:type="int">42</object> <object xj:name="active" xj:type="boolean">true</object> <object xj:name="ranking" xj:type="float">3.1415926</object> <object xj:name="roles" xj:type="array"> <object xj:type="string">a</object> <object xj:type="object"> <object xj:name="x" xj:type="null">null</object> </object> </object> <object xj:name="state" xj:type="object"> <object xj:name="needsWater" xj:type="boolean">true</object> </object> </object>
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xj="http://camel.apache.org/component/xj" exclude-result-prefixes="xj"> <xsl:output omit-xml-declaration="no" encoding="UTF-8" method="xml" indent="yes"/> <xsl:template match="/"> <person> <xsl:apply-templates select="//object"/> </person> </xsl:template> <xsl:template match="object[@xj:type != 'object' and @xj:type != 'array' and string-length(@xj:name) > 0]"> <xsl:variable name="name" select="@xj:name"/> <xsl:element name="{USDname}"> <xsl:value-of select="text()"/> </xsl:element> </xsl:template> <xsl:template match="@*|node()"/> </xsl:stylesheet>
from("direct:start"). to("xj:com/example/json2xml.xsl?transformDirection=JSON2XML");
<?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber>42</personalnumber> <active>true</active> <ranking>3.1415926</ranking> <x>null</x> <needsWater>true</needsWater> </person>
from("direct:start"). to("xj:identity?transformDirection=XML2JSON");
<?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber>42</personalnumber> <active>true</active> <ranking>3.1415926</ranking> <roles> <entry>a</entry> <entry> <x>null</x> </entry> </roles> <state> <needsWater>true</needsWater> </state> </person>
{ "firstname": "camel", "lastname": "apache", "personalnumber": "42", "active": "true", "ranking": "3.1415926", "roles": [ "a", { "x": "null" } ], "state": { "needsWater": "true" } }
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xj="http://camel.apache.org/component/xj" exclude-result-prefixes="xj"> <xsl:output omit-xml-declaration="no" encoding="UTF-8" method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="personalnumber"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'int'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="active|needsWater"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'boolean'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="ranking"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'float'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="roles"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'array'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="*[normalize-space(text()) = 'null']"> <xsl:element name="{local-name()}"> <xsl:attribute name="xj:type"> <xsl:value-of select="'null'"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
from("direct:start"). to("xj:com/example/xml2json.xsl?transformDirection=XML2JSON");
{ "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } }
<?xml version="1.0" encoding="UTF-8"?> <person> <firstname>camel</firstname> <lastname>apache</lastname> <personalnumber xmlns:xj="http://camel.apache.org/component/xj" xj:type="int">42</personalnumber> <active xmlns:xj="http://camel.apache.org/component/xj" xj:type="boolean">true</active> <ranking xmlns:xj="http://camel.apache.org/component/xj" xj:type="float">3.1415926</ranking> <roles xmlns:xj="http://camel.apache.org/component/xj" xj:type="array"> <entry>a</entry> <entry> <x xj:type="null">null</x> </entry> </roles> <state> <needsWater xmlns:xj="http://camel.apache.org/component/xj" xj:type="boolean">true</needsWater> </state> </person>
<?xml version="1.0" encoding="UTF-8"?> <object xmlns:xj="http://camel.apache.org/component/xj" xj:type="object"> <object xj:name="firstname" xj:type="string">camel</object> <object xj:name="lastname" xj:type="string">apache</object> <object xj:name="personalnumber" xj:type="int">42</object> <object xj:name="active" xj:type="boolean">true</object> <object xj:name="ranking" xj:type="float">3.1415926</object> <object xj:name="roles" xj:type="array"> <object xj:type="string">a</object> <object xj:type="object"> <object xj:name="x" xj:type="null">null</object> </object> </object> <object xj:name="state" xj:type="object"> <object xj:name="needsWater" xj:type="boolean">true</object> </object> </object>
{ "firstname": "camel", "lastname": "apache", "personalnumber": 42, "active": true, "ranking": 3.1415926, "roles": [ "a", { "x": null } ], "state": { "needsWater": true } }