Skip to main content
Version: 4.17.3

XML to JSON component

The XML to JSON component allows you to convert XML files into JSON files.

Configuration

The XML to JSON component has the following basic configuration options:

Force Top Level Object

Specify whether the resulting JSON will start off with a top-most element whose name matches the XML root element.

Options

  • Yes
  • No (default)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<person>
<name>John Johnson</name>
<age>19</age>
</person>
<person>
<name>John Foo</name>
<age>30</age>
</person>
<person>
<name>John Doe</name>
<age>30</age>
</person>
</root>

Skip whitespace

Specify whether white spaces between XML elements will be interpreted as text values or will be ignored.

Options

  • Yes
  • No (default)

Trim spaces

Specify whether leading and trailing white spaces will be omitted from string values.

Options

  • Yes
  • No (default)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<person>
<name> John Johnson </name>
<age>19</age>
</person>
<person>
<name>John Foo</name>
<age>30</age>
</person>
<person>
<name>John Doe</name>
<age>30</age>
</person>
</root>

Skip namespaces

Specify whether to remove namespaces from the JSON output. By default they will be added to the JSON output using @xmlns.

Options

  • Yes
  • No (default)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<h:table xmlns:h="http://www.dovetail.world/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="https://www.dovetail.world/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>

Remove namespace prefixes

Specify whether to remove namespace prefixes from XML node names.

Options

  • Yes
  • No (default)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<h:table xmlns:h="http://www.dovetail.world/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="https://www.dovetail.world/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>

Type Hints

Adds type hints to the resulting XML to aid conversion back to JSON. Used for unmarshalling (JSON to XML conversion)

Options

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

Using XML to JSON

Empty XML nodes

Empty XML nodes, like <Reference_two/> or <Reference_two></Reference_two> will be converted into empty JSON arrays: "Reference_two" : [].

Last update on Feb 25, 2025