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 |
Coverts the input data from JSON to XML and vice-versa. |
Preconfigured? |
No. The system invokes the BP. |
Requires third-party files? |
Yes. The json-20170516.jar file is used as a third-party file. |
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.
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>input'>{"student":{"name":"XYZ","age":"22"}}</input>
<Output><student><name>XYZ</name><age>22</age></student></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'>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>