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:
Property | Default | Description |
---|---|---|
Element name | e | Specifies the name of the XML tags representing array element |
Array name | a | Specifies 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 name | none | When 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 lenient | false | Whether to tolerate incomplete namespace prefixes |
Type Hints | false | Adds 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:
Property | Value |
---|---|
Element name | OrderList |
Array name | Order |
Root name | KabisaOrder |
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:
Property | Value |
---|---|
Element name | Element |
Array name | Array |
Root name | Formula1 |
TypeHints | true |
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>