JSON to XML Current component
The JSON to XML Current component provides a direct conversion from the JSON format to the XML format.
Configuration
It has the following configuration options:
Keep in mind that each enabled option could take some extra time to complete the transformation.
Add a root tag?
Options
yes
no
(default)
Description
By default the component won't add a root tag around the resulting XML. By selecting
yes
a root tag called root
will be added that wraps the resulting XML.
Example
{
"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>
When a JSON key contains invalid XML characters
Options
filter these characters
don't filter these characters and go to the error route
(default)
Description
By default the component won't filter invalid XML characters from the JSON keys. This
could lead to errors which will direct the exchange to the error route. If you're
not sure if the JSON could contain invalid XML characters in the JSON keys you
can select filter these characters
.
The following rules apply for the filter:
- Names can't start with a digit
- Names can't start with special characters like hypens or periods
- Names can't start with any variation of 'xml'
- Names can't contain special characters other than the period, hyphen, underscore, and colon
Some JSON keys that could never be valid as an XML element on their own
are prepended with element-
.
Example
Notice that the JSON key "123"
becomes the XML element element-123
.
{
"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>