JSON to XML Simple component
The JSON to XML Simple component allows you to convert JSON formatted input into XML output directly.
Configuration
The JSON to XML Simple component has the following configuration options:
Add a root tag?
By default the component won't add a root tag around the resulting XML. Selecting Yes
will add a root tag that wraps the XML output.
Options
Yes
No
(default)
If the JSON starts with an array, add a root tag to ensure the XML output is valid.
See the example below:
- JSON Input
- XML Output - Root tag disabled
- XML Output - Root tag enabled
{
"Formula1": {
"Drivers": {
"Driver": [
{
"Age": 19,
"Name": "Max Verstappen"
},
{
"Age": 30,
"Name": "Nico Hulkenberg"
}
]
},
"Teams": {
"Team": [
{
"Principal": "Christian Horner",
"Name": "Redbull Racing"
},
{
"Principal": "Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul",
"Name": "Renault"
}
]
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Formula1>
<Drivers>
<Driver>
<Age>19</Age>
<Name>Max Verstappen</Name>
</Driver>
<Driver>
<Age>30</Age>
<Name>Nico Hulkenberg</Name>
</Driver>
</Drivers>
<Teams>
<Team>
<Principal>Christian Horner</Principal>
<Name>Redbull Racing</Name>
</Team>
<Team>
<Principal>Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
<Name>Renault</Name>
</Team>
</Teams>
</Formula1>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Formula1>
<Drivers>
<Driver>
<Age>19</Age>
<Name>Max Verstappen</Name>
</Driver>
<Driver>
<Age>30</Age>
<Name>Nico Hulkenberg</Name>
</Driver>
</Drivers>
<Teams>
<Team>
<Principal>Christian Horner</Principal>
<Name>Redbull Racing</Name>
</Team>
<Team>
<Principal>Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
<Name>Renault</Name>
</Team>
</Teams>
</Formula1>
</root>
Root tag name
Specify a custom root tag. The default value is root
.
Only available when Add a root tag? is enabled.
- Start with a digit.
- Start with special characters such as hyphens or periods.
- Start with any variation of
xml
. - Contain special characters other than the periods, hyphens, underscores and/or colons.
When a JSON key contains invalid XML characters
Specify whether invalid XML characters should be filtered out when converting JSON keys.
Options
Filter these characters
Don't filter these characters and go to the error route
(default)
By default, the component does not filter invalid XML characters from JSON keys. This may cause errors, directing the exchange to the error route. If you're unsure whether the JSON contains invalid XML characters in the keys, we suggest to enable filtering.
Some JSON keys that are never valid as XML elements are automatically prepended with element-
.
- Start with a digit.
- Start with special characters such as hyphens or periods.
- Start with any variation of
xml
. - Contain special characters other than the periods, hyphens, underscores and/or colons.
See the example below:
- JSON Input
- XML Output - Filter enabled
{
"Formula1": {
"Drivers": {
"Driver": [
{
"A!ge": 19,
"Na>me": "Max Verstappen"
},
{
"Ag?e": 30,
"Nam<>e": "Nico Hulkenberg"
}
]
},
"Tea#@ms": {
"!Tea!m": [
{
"!@!Principal": "Christian Horner",
"12Name!": "Redbull Racing"
},
{
"45Principa!l": "Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul",
"xmlName": "Renault"
}
]
},
"123": "example"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Formula1>
<element->another example</element->
<Drivers>
<Driver>
<Age>19</Age>
<Name>Max Verstappen</Name>
</Driver>
<Driver>
<Age>30</Age>
<Name>Nico Hulkenberg</Name>
</Driver>
</Drivers>
<element-123>example</element-123>
<Teams>
<Team>
<Principal>Christian Horner</Principal>
<Name>Redbull Racing</Name>
</Team>
<Team>
<Principal>Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
<Name>Renault</Name>
</Team>
</Teams>
</Formula1>
</root>
Change the name of array elements?
By default, the component uses the name of the JSON key for an array to name the nodes in the resulting XML. Select Yes
to override this behavior.
Options
Yes
No
(default)
See the example below:
- JSON Input
- XML Output - Rename disabled
- XML Output - Rename enabled
{
"Formula1": {
"Drivers": {
"Driver": [
{
"Age": 19,
"Name": "Max Verstappen"
},
{
"Age": 30,
"Name": "Nico Hulkenberg"
}
]
},
"Teams": {
"Team": [
{
"Principal": "Christian Horner",
"Name": "Redbull Racing"
},
{
"Principal": "Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul",
"Name": "Renault"
}
]
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Formula1>
<Drivers>
<Driver>
<Age>19</Age>
<Name>Max Verstappen</Name>
</Driver>
<Driver>
<Age>30</Age>
<Name>Nico Hulkenberg</Name>
</Driver>
</Drivers>
<Teams>
<Team>
<Principal>Christian Horner</Principal>
<Name>Redbull Racing</Name>
</Team>
<Team>
<Principal>Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
<Name>Renault</Name>
</Team>
</Teams>
</Formula1>
<?xml version="1.0" encoding="UTF-8"?>
<Formula1>
<Drivers>
<element>
<Age>19</Age>
<Name>Max Verstappen</Name>
</element>
<element>
<Age>30</Age>
<Name>Nico Hulkenberg</Name>
</element>
</Drivers>
<Teams>
<element>
<Principal>Christian Horner</Principal>
<Name>Redbull Racing</Name>
</element>
<element>
<Principal>Carlos Ghosn, Jérôme Stoll, Cyril Abiteboul</Principal>
<Name>Renault</Name>
</element>
</Teams>
</For
Array element name
Specify a custom name for array elements. The default value is element
.
Only available when Change the name of array elements? is enabled.
- Start with a digit.
- Start with special characters such as hyphens or periods.
- Start with any variation of
xml
. - Contain special characters other than the periods, hyphens, underscores and/or colons.