# 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](https://documentation.astera.com/dataflows/sources/excel-workbook-source).

<img src="/files/TvgK6iYQMtbRrg9nGs59" alt="" width="282">

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.

<img src="/files/VrK4x6XA5IZjZz0zq8JV" alt="" width="375">

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

![](/files/rVfUNZldKNzZYOTOGup9)

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.

   <figure><img src="/files/BEG7Q4OrTi9qvETyzaqn" alt=""><figcaption></figcaption></figure>
2. Map the *Text* field in *Customer\_Orders* object to the *Text* field in the *JSON Parser* object.<br>

   <figure><img src="/files/kfO5It6UpSI6n6Irfves" alt="" width="546"><figcaption></figcaption></figure>
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.

   <img src="/files/FErOgrHeq5XUOacYc8M6" alt="" width="375">

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

   <figure><img src="/files/WbqMGFKi39nQDWavNj5H" alt="" width="354"><figcaption></figcaption></figure>

   * *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.

<img src="/files/EkVstI3Ks4UM1Mcte88X" alt="" width="375">

4. Once you are satisfied with the layout click *OK.*

<figure><img src="/files/oYOoNdCD1Xju1wvxi3w0" alt="" width="563"><figcaption></figcaption></figure>

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

5. 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.

<figure><img src="/files/AMeRWpz5mgfALUzsxAsG" alt=""><figcaption></figcaption></figure>

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

6. 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.

<figure><img src="/files/i8pcnng4GtbEyifJelIT" alt="" width="563"><figcaption></figcaption></figure>

7. Configure settings for the [*JSON File Destination*](/dataflows/destinations/json-file-destination.md) object.
8. Click on the *Start Dataflow* button in the toolbar to create the destination file.

<figure><img src="/files/dtuGGBzDf17GYjWT3Ol6" alt=""><figcaption></figcaption></figure>

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.astera.com/dataflows/text-processors/json-parser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
