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.
In this case, we are using an XML/JSON File Source.
The XML/JSON File Source contains the hierarchical data of customers, their orders, and the order details.
Right-click on the header of the XML/JSON File Source object and select the Preview Output option to visualize the hierarchical data.
View the source data from the Data Preview window.
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 Object¶
1. Select the XML/JSON Serializer object from the toolbox window and drag-and-drop it onto the dataflow designer.
2. Right-click on the header of the XML/JSON Serializer and select the Properties option from the context menu.
A configuration window will open, as shown below.
3. Provide the file path for the XML Schema i.e., the structure or layout of the XML File.
- Check the JSON Format option if your file is a JSON.
Click on 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.
Now, click on OK to proceed further.
4. Map the fields of the XML/JSON File Source object onto the XML/JSON Serializer object’s fields.
5. Right-click on object’s header and select Preview Output.
You can view the data through Data Preview window.
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, click on Write To and select your desired destination object. A destination object is created on the dataflow designer with the Text field auto-mapped.
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.
By running this dataflow, you can now create an Excel file containing the serialized XML output.
This is how an XML Serializer Object can be used in Astera Centerprise to format hierarchical data into a single stream of text.