XML/JSON Serializer

XML/JSON Serializer reads hierarchical data and converts it into a text stream. It is basically the conversion of data in structured format to a single stream in a text-like format.

Sample Use-Case

In this case, we are using an XML/JSON File Source.

01-XMLSourceFile

The XML/JSON File Source contains the hierarchical data of customers, their orders, and the order details.

Right-click on the XML/JSON File Source object’s header, and select the Preview Output to visualize the hierarchical data.

02-XML-PreviewOutputMenu

View the source data from the Data Preview window.

03-XML-PreviewOutput

Now, to convert this hierarchical data into a single text stream, we will use the XML/JSON Serializer object.

Steps to Use the XML/JSON Serializer

1. Select the XML/JSON Serializer object from the Toolbox window and drag-and-drop it onto the dataflow designer.

04-dataflow-XMLSerializer

2. Right-click on the XML/JSON Serializer object’s header, and select Properties from the context menu.

05-SerializerObject-Properties

A configuration window will open, as shown below.

06-XMLSerializer-ConfigurationWindow

3. Provide the File Path for the XML Schema i.e., the structure or layout of the XML File.

07-XMLSerializer-SchemaPath

  • Check the JSON Format option if your file is a JSON.

08-XMLSerializer-LayoutBuilder

Click Next. This is the Config Parameters window, which allows us to configure and define certain parameter for the XML Serializer Source file.

Use of Parameters eliminates the process of inserting hardcoded values and provides simplification in the deployment of flows. If the parameters are left empty, the default values defined at the Properties window are assigned for use.

09-XMLSerializer-ConfigParameter

Now, click OK, to proceed further.

4. Map the fields of the XML/JSON File Source object onto the XML/JSON Serializer object’s fields.

10-XMLSerializer-Mapping

5. Right-click on the object’s header, and select Preview Output.

11-XMLSerializer-PreviewOutputMenu

You can view the data through Data Preview window.

12-XMLSerializer-PreviewOutput

Hover over the Text field and you will see the Serialized output i.e., stream of text for each hierarchical record of the XML/JSON file.

To store the Serialized Output, we must write it to a destination file.

6. Right-click on the XmlJsonSerializer, select Write To, and select your desired destination object. A destination object is created on the dataflow designer with the Text field auto mapped.

13-XMLSerializer-ToOutput

Here, we have used an Excel Workbook Destination object.

7. Right-click on the destination object’s header and provide the File Path for the destination file. Select the relevant options and click OK.

14-ExcelDestination-ConfigurationWindow

By running this dataflow, you can now create an Excel file containing the serialized XML output.

15-Excel-Output

This is how an XML Serializer Object can be used to format hierarchical data into a single stream of text in Astera Centerprise.