EN-US
Ask or search…
K
Links

XML to JSON Transformer

Discover more about the XML to JSON Transformer component and how to use it on the Digibee Integration Platform.
XML to JSON Transformer transforms an XML string into a JSON object.

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).
Parameter
Description
Default value
Data type
XML Field Path
Field path of the XML string to be transformed. This path representation must be made in dotted notation. If the field is a matrix, all the elements of this matrix will be run. You can specify multiple fields, separating them by comma.
body
String
Preserve Original
If the option is enabled, the original fields are preserved in the transformation result and, to differ the name of the transformed fields, the “_” character will be added in the beginning of the name of the original fields.
True
Boolean
With Namespace
If the option is enabled, the XML namespaces will be kept in the transformation result.
True
Boolean
Remove XML Attributes
If the option is enabled, the XML attributes will be hidden in the transformation result.
False
Boolean
All Values As String
If the option is enabled, all XML tag values will be transformed to string type.
False
Boolean

Messages flow

Input

The component doesn’t expect a specific input message, just the XML Field Path configuration parameter to be filled with a reference to the path of the field to be transformed. This field must exist in the message of the step prior to the XML to JSON Transformer execution.

Output

The structure will be the same as the one received in the previous step of the flow, but the fields informed in the XML Field Path parameter will be transformed in the JSON object representation. In case of error, the “error” property will be created at the same level as the original property.
When the Preserve Original parameter is enabled, for each field informed in the XML Field Path parameter, a new property will be informed just by adding the “_” character at the beginning of its name and containing the original XML string.
The JSON dotted notation will look for the root element that is being processed by the pipeline and cross it according to the specification provided in the XML Field Path property.
Example:
In an XML Field Path representation with a.b.c.d, "a" will be searched in the root element. Afterwards, it will be “b”, then "c" and finally "d". If an array is found during the cross-process, the algorithm will create a cross path for each array element. The algorithm replaces all the path occurrences defined in XML Field Path.

XML to JSON Transformer in action

For all the scenarios below, the following payload will be considered with the XML String field:
{
"xmlField": "<?xml version=\"1.0\" ?><inf:ProductInformation xmlns:inf=\"urn:product:Info\" xmlns:stk=\"urn:product:Stock\"><inf:ProductName Code=\"C00001\">Computer</inf:ProductName><inf:Price Units=\"$\">2500</inf:Price><stk:Volume Units=\"Units\">200</stk:Volume></inf:ProductInformation>"
}

XML Transformation

Input

Parameters
  • XML Field Path: xmlField
  • Preserve Original: false
  • With Namespace: false
  • Remove XML Attributes: false
  • All Values As String: false

Output

{
"xmlField": {
"ProductInformation": {
"ProductName": {
"Code": "C00001",
"content": "Computer"
},
"Price": {
"Units": "$",
"content": 2500
},
"Volume": {
"Units": "Units",
"content": 200
},
"xmlns:stk": "urn:product:Stock",
"xmlns:inf": "urn:product:Info"
}
}
}

XML Transformation with the Preserve Original parameter enabled

Input

Parameters
  • XML Field Path: xmlField
  • Preserve Original: true
  • With Namespace: false
  • Remove XML Attributes: false
  • All Values As String: false

Output

{
"xmlField": {
"ProductInformation": {
"ProductName": {
"Code": "C00001",
"content": "Computer"
},
"Price": {
"Units": "$",
"content": 2500
},
"Volume": {
"Units": "Units",
"content": 200
},
"xmlns:stk": "urn:product:Stock",
"xmlns:inf": "urn:product:Info"
}
},
"_xmlField": "<?xml version=\"1.0\" ?><inf:ProductInformation xmlns:inf=\"urn:product:Info\" xmlns:stk=\"urn:product:Stock\"><inf:ProductName Code=\"C00001\">Computer</inf:ProductName><inf:Price Units=\"$\">2500</inf:Price><stk:Volume Units=\"Units\">200</stk:Volume></inf:ProductInformation>"
}

XML Transformation with the With Namespace parameter enabled

Input

Parameters
  • XML Field Path: xmlField
  • Preserve Original: false
  • With Namespace: true
  • Remove XML Attributes: false
  • All Values As String: false

Output

{
"xmlField": {
"inf:ProductInformation": {
"inf:Price": {
"Units": "$",
"content": 2500
},
"xmlns:stk": "urn:product:Stock",
"xmlns:inf": "urn:product:Info",
"inf:ProductName": {
"Code": "C00001",
"content": "Computer"
},
"stk:Volume": {
"Units": "Units",
"content": 200
}
}
}
}

XML Transformation with the Remove XML Attributes parameter enabled

Input

Parameters
  • XML Field Path: xmlField
  • Preserve Original: false
  • With Namespace: false
  • Remove XML Attributes: true
  • All Values As String: false

Output

{
"xmlField": {
"ProductInformation": {
"ProductName": "Computer",
"Price": 2500,
"Volume": 200
}
}
}

XML Transformation with the All Values As String parameter enabled

Input

Parameters
  • XML Field Path: xmlField
  • Preserve Original: false
  • With Namespace: false
  • Remove XML Attributes: true
  • All Values As String: true

Output

{
"xmlField": {
"ProductInformation": {
"ProductName": "Computer",
"Price": "2500",
"Volume": "200"
}
}
}
Last modified 1mo ago