XML JSON Serializer
XML/JSON Serializer reads hierarchical data and converts it into a text stream. It is basically the conversion of data in a 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.
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.
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.
Using the XML/JSON Serializer
Select the XML/JSON Serializer object from the Toolbox window and drag and drop it onto the dataflow designer.
Right-click on the XML/JSON Serializer object’s header, and select Properties from the context menu.
A configuration window will open, as shown below.
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 Next. This is the Config Parameters window, which allows us to configure and define certain parameters for the XML Serializer Source file.
The 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 in the Properties window are assigned for use.
Now, click OK, to proceed further.
Map the fields of the XML/JSON File Source object onto the XML/JSON Serializer object’s fields.
Right-click on the object’s header, and select Preview Output.
You can view the data through the 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.
Writing to a Destination
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.
Here, we have used an Excel Workbook Destination object.
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 to format hierarchical data into a single stream of text in Astera.
Last updated