Skip to main content
Version: 4.15.0

JSON to XML component

The JSON to XML component provides a direct conversion from the JSON format to XML format. This component could, for example, be used when you receive JSON data from an Inbound HTTP component.

Configuration

The JSON to XML component has the following configuration options:

PropertyDefaultDescription
Element nameeSpecifies the name of the XML tags representing array element
Array nameaSpecifies the name of the top-level XML element. For example, when converting [1, 2, 3], it will be output by default as <a><e>1</e><e>2</e><e>3</e></a>. By setting this option or rootName, you can alter the name of element 'a'
Root namenoneWhen converting any JSON object to XML, it specifies the name of the top-level element. If not set, it wil use o as a default value. If set to 'root', the JSON string { 'x': 'value1', 'y' : 'value2' } would turn into <root><x>value1</x><y>value2</y></root>, otherwise the 'root' element would be named 'o'
Namespace lenientfalseWhether to tolerate incomplete namespace prefixes
Type HintsfalseAdds type hints to the resulting XML to aid conversion back to JSON. Used for unmarshalling (JSON to XML conversion).

Example

1 - Order Example

Let's assume the JSON to XML component is configured as with the following settings:

PropertyValue
Element nameOrderList
Array nameOrder
Root nameKabisaOrder

When given the input…

{
"order_numbers" : [
"201406",
"201407",
"201408"
]
}

… the JSON to XML component will yield the following output:

<KabisaOrder>
<OrderList>
<Order>201406</Order>
<Order>201407</Order>
<Order>201408</Order>
</OrderList>
</KabisaOrder>

2 - Complex Example

Let's assume the JSON to XML component is configured as with the following settings:

PropertyValue
Element nameElement
Array nameArray
Root nameFormula1
TypeHintstrue

When given the input…

{
"Drivers": [
{
"Name": "Max Verstappen",
"Age": 19
},
{
"Name": "Nico Hulkenberg",
"Age": 30
}
],
"Teams": [
{
"Name": "Redbull Racing",
"Principal": "Christian Horner"
},
{
"Name": "Renault",
"Principal": "Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul"
}
]
}

… the JSON to XML component will yield the following output:

<?xml version="1.0" encoding="UTF-8"?>
<Formula1>
<Drivers class="array">
<Element class="object">
<Age type="number">19</Age>
<Name type="string">Max Verstappen</Name>
</Element>
<Element class="object">
<Age type="number">30</Age>
<Name type="string">Nico Hulkenberg</Name>
</Element>
</Drivers>
<Teams class="array">
<Element class="object">
<Name type="string">Redbull Racing</Name>
<Principal type="string">Christian Horner</Principal>
</Element>
<Element class="object">
<Name type="string">Renault</Name>
<Principal type="string">Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
</Element>
</Teams>
</Formula1>