JSON Parser

The JSON Parser reads and processes a single stream of text in a JSON format as input and returns its elements as a parsed output in JSON format. It enables users to transform an otherwise semi-structured data into a structured hierarchical format.

In this document, we will learn how to use the JSON Parser to parse an incoming text stream in Astera.

Use Case

In this case, we are using an Excel Workbook Source.

This source file contains hierarchical details of customer’s orders.

To preview data, right-click on the source object’s header and select Preview Output from the context menu.

A Data Preview window will open, displaying the source data.

Observe that it is difficult to decipher fields and elements when the data is in a text stream. To make sense of this data, it needs to be structured in a proper hierarchical format.

To parse this source data, we will use the JSON Parser object in Astera.

Using JSON Parser

  1. To get the JSON Parser object, go to Toolbox > Text Processors > Parser and drag-and-drop the object onto the designer. You can see that the dragged object contains a Text field.

  2. Map the Text field in Customer_Orders object to the Text field in the JSON Parser object.

  3. Next, we need to define the layout of our parsed output. Astera provides a few ways to define the layout:

    • Run Flow to Generate Layout: Right-click the object’s header and select Run Flow to Generate Layout to automatically generate the layout based on the flow output.

    • Manual Layout Configuration: Right-click the header and select Properties. In the layout screen, you can define the preferred layout manually.

    • Generate from Sample Text: In the layout window, you can also use the Generate Layout by Providing Sample Text option to auto-generate the layout using an example input.

  1. Once you are satisfied with the layout click OK.

The data stream is parsed into regions and fields which can be seen on the JSON Parser object.

  1. Right-click on the object’s header and select Preview Output from the context menu. A Data Preview window will open. Expand the nodes, and you will see the parsed output for each record.

To store this parsed output, write it to a destination.

  1. Right-click on the Output node under JSON Parser object, go to Write to > JSON File Destination. A JSON File Destination object is added to the dataflow designer with all fields auto-mapped to it.

  1. Configure settings for the JSON File Destination object.

  2. Click on the Start Dataflow button in the toolbar to create the destination file.

A JSON destination file will be successfully created, with parsed output in JSON format.

Last updated

Was this helpful?