XML JSON Transformer service
The XML JSON Transformer service converts the XML or JSON input data to the desired format.
The following table provides an overview of the XML-JSON Transformer service:
System Name |
xmljsontransformer |
Graphical Process Modeler (GPM) category |
All Services |
Description |
Leverages the Sterling B2B Integrator Workflow manager (Business Processes) to convert XML or JSON input data to the desired format. |
Business usage |
Converts the input data from JSON to XML and vice-versa. |
Preconfigured? |
No. The system invokes the BP. |
Requires third-party files? |
Yes. The following third party jars are used:
|
Platform availability |
All supported Sterling B2B Integrator platforms |
Related services |
None |
Application requirements |
None |
Initiates business processes? |
Yes |
Invocation |
The XML-JSON Transformer service is included in a predefined |
Business process context considerations |
JSON to XML conversion: Input Type = JSON Output file = XML to JSON conversion: Input Type = XML Note: In case of XML as an Input, the angular brackets must be replaced with escape characters as
follows:
1. ‘<’ with ‘<’ 2. ‘>’ with ‘>’ For example: <tag>tagdata<tag> Output file =
output.json Note:
The result of the |
Returned status values |
The desired data format (XML or JSON) is stored in the |
Restrictions |
None |
Persistence level |
None |
Testing considerations |
None |
You can give the input for the service either using a business process or using a text file.
- Parameter changes in BPML - The case of the parameters is changed to
Input
,InputType
, andOutputPath
frominput
,inputtype
, andoutputpath
respectively. - XML to JSON conversion - order of elements is not maintained in the output JSON.
- JSON to XML conversion -
- A default root element
<root>
is inserted in the output XML file after conversion. - If the input JSON file contains any key with empty array as value, then that key is not
converted. The output XML file does not have this key/value.
Input JSON: {"orders":[]}
Output XML: <root></root>
- The maximum JSON file size supported for conversion is 50 MB.
- A default root element
- In Windows environment, if the output needs to be redirected to a file system, then the complete file path location needs to be specified in the BPML.
Using a business process
<process name="xmljsontransformer">
<sequence>
<operation name="Request">
<participant name='xmljsontransformer'/>
<output message='xout'>
<assign to='Input'><hello>world</hello></assign>
<assign to='InputType'>XML</assign>
<assign to='OutputPath'>output.json</assign>
<assign to='.' from='*'/>
</output>
<input message="xin">
<assign to='.' from='*'/>
</input>
</operation>
</sequence>
</process>
Process Name: xmljsontransformer Instance ID: 267252
Service Name: xmljsontransformer
<?xmlversion="1.0" encoding="UTF-8"?>
<ProcessData>
<input_type>XML</input_type>
<Input><hello>world</hello></input>
<Output>{"hello":"world"}</Output>
</ProcessData>
<process name="xmljsontransformer">
<sequence>
<operation name="Request">
<participant name='xmljsontransformer'/>
<output message='xout'>
<assign to='Input'>{"student":{"name":"XYZ","age":"22"}}</assign>
<assign to='InputType'>JSON</assign>
<assign to='OutputPath'>output.xml</assign>
<assign to='.' from='*'/>
</output>
<input message="xin">
<assign to='.' from='*'/>
</input>
</operation>
</sequence>
</process>
Process Name: xmljsontransformer Instance ID: 267252
Service Name: xmljsontransformer
<?xmlversion="1.0" encoding="UTF-8"?>
<ProcessData>
<input_type>JSON</input_type>
<Input>{"student":{"name":"XYZ","age":"22"}}</input>
<Output><root><student><name>XYZ</name><age>22</age></student></root></Output>
</ProcessData>
Using a text file
Input.txt
{"certificate":{"certName":"Demo","certData":"demodata"}}
<process name="xmljsontransformer">
<sequence>
<operation name="Request">
<participant name='xmljsontransformer'/>
<output message='xout'>
<assign to='.' from='PrimaryDocument/@SCIObjectID'></assign>
<assign to='InputType'>JSON</assign>
<assign to='OutputPath'>C:\IBM\SI601\noapp\output.xml</assign>
<assign to='.' from='*' />
</output>
<input message="xin">
<assign to='.' from='*' />
</input>
</operation>
</sequence>
</process>
Input.txt
<hello>World</hello>
<process name="xmljsontransformer">
<sequence>
<operation name="Request">
<participant name='xmljsontransformer'/>
<output message='xout'>
<assign to='.' from='PrimaryDocument/@SCIObjectID'></assign>
<assign to='InputType'>XML</assign>
<assign to='OutputPath'>output.json</assign>
<assign to='.' from='*'/>
</output>
<input message="xin">
<assign to='.' from='*'/>
</input>
</operation>
</sequence>
</process>