Skip to main content
Version: 4.14.6

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 will be added that wraps the resulting XML. By default it will be called root, but you can rename it in the Specify root tag name option.

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"
}
]
}
}
}

Specify root tag name

Description

This option allows you to specify a custom root tag. By default it will be root.

Remarks

  • This field only becomes visible when you want to add a root tag to the resulting XML.
  • Simple headers can be specified to create a dynamic root tag.
    • Example: ${header.headerName}
  • Since it will be used in an XML element the following rules apply:
    • 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

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"
}
}

Change the name of array elements?

Options

  • yes
  • no (default)

Description

By default the component will use the name of the JSON key of the an array to name the nodes in the resulting XML. To change this behaviour you can select yes and specify the name you want to use in the option: Specify the custom array element name.

Examples


{
"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"
}
]
}
}
}

Specify the custom array element name

Description

This option allows you to specify a name for array elements. By default it will be element.

Remarks

  • This field only becomes visible when you want to specify a custom array element name.
  • Simple headers can be specified to create a dynamic array element name.
    • Example: ${header.headerName}
  • Since it will be used in an XML element the following rules apply:
    • 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.

Remarks

JSON with root array

When the JSON starts with an array like this:


[
{
"key": "value"
}
]

You need to set Add a root tag? to yes. Otherwise invalid XML will be generated that will result in an exception.