JSON to XML

JSON to XML

One of the valid input formats of InterFormNG2 is JSON files. If you e.g. want to data in an input JSON file in either an email or in a template, then you first need to convert the JSON file into XML. You can use the basic, converter workflow component, JSON to XML for that.

 

In order to select this component the payload must be JSON e.g. by selecting JSON as the input file type in the workflow.

 

The component has no input parameters:

 

NG2JSON2XML0001

 

The input JSON may contain objects with no value and arrays. They are created as nodes with a dummy names in the output XML.

 

 

Exceptions for the field name to XML node conversion

The field names of the input JSON file are converted into XML nodes with the same name as the JSON field with these exceptions:

 

The supported characters in the field names are the characters in the ranges: a-z, A-Z and numbers: 0-9. Any other character in the field name are replaced with an underscore, "_".

If the field name starts with a number a preceding underscore is added to the XML node.

 

 

Exceptions for the value conversion

The value of the JSON fields are copied into the value of the output XML file with this exception:

The conversion removes all illegal XML letters (e.g. character values below 32, except newline and carriage return).

 

 

Example

If you e.g. convert this JSON file:

 

NG2JSON2XML0002

 

Then the component will convert it into this XML file:

NG2JSON2XML0003

 

You can verify the output of the conversion e.g. with the To filesystem component:

 

NG2JSON2XML0004

 

You can also use the converted XML file as input for a merge with a template into e.g. printemail or PDF or transform the XML file before merging it.

    • Related Articles

    • JSON

      JSON files can be used as a data container very similar to an XML file. JSON files are supported as input in the workflows and also in the JSON to XML workflow component. With the XSL transformation workflow component you can also convert XML files ...
    • XML

      XML is used widely in InterFormNG2 as both input and output payload in the workflow (and of course in the designer). Please notice, that some workflow components are listed as accepting only XML as input, where they actually also accept an IBM i ...
    • Split XML

      This advanced converter workflow component can split up an XML in the payload of the current workflow. The subtree of this workflow component is executed for each splitted XML. A similar component, which is also able to transform the splitted files, ...
    • XML remove namespaces

      This advanced utilities workflow component removes all name spaces from the XML file in the workflow payload. The workflow continues processing on the changed XML. The XML remove namespaces workflow component has no parameters.
    • SPLF to XML

      With the spooled file extractor you can create transformations (with the extension .sfe), that can convert a spooled file into XML. These transformations can be linked directly in a template, so that the spooled file is converted directly into XML, ...