2. Enterprise Integration Patterns

json2Xml

Version

Converts a JSON message body to XML. A body that is not JSON passes through unchanged. The result is UTF-8 encoded, begins with an XML prolog, and the Content-Type is set to application/xml. If the body is not valid JSON the exchange is aborted with a 500 Problem Details. See the examples under examples/message-transformation/json2xml and the tutorial tutorials/xml/10-JSON-to-XML.yaml.

Example Configuration

api:
port: 2000
flow:
- json2Xml:
root: order
api:
   port: 2000
   flow:
     - json2Xml:
         root: order

Syntax

json2Xml:
array: <string>
item: <string>
root: <string>
json2Xml:
  array: <string>
  item: <string>
  root: <string>

Attributes

NameRequiredDefaultDescriptionExamples
arrayfalsearrayXML element name wrapped around every JSON array, nested ones included.items
itemfalseitemXML element name used for each item of a JSON array.entry
rootfalsederived from the JSONName of the single XML root element the converted document is wrapped in. When set, every result is wrapped in an element with this name. When unset, the name is derived from the document: a single-property object uses that property as the root, a top-level array uses the array element name, and any other object or value is wrapped in root.order

Can be used in