# JSONTODATA

## Overview

The **JSONTODATA** workflow application lets you parse JSON content into process data.

## How it works

* The JSONTODATA application requires either the `JSON_CONTENT` or the `JSON_CONTENT_FILE` parameter; these correspond to the JSON to parse.<br>
* The application supports the JSONPath query language (see [https://github.com/json-path/JsonPath](https://github.com/json-path/JsonPath\\)), which allows extraction of specific data from JSON content, similar to XPath expressions in XML.<br>
* Application logs are available. These can be specified by setting the value of the  `JsonToDataLogLevel` parameter in the `web.config` file to `0` to deactivate logs, `1` for error logs, `2` for information logs, or `3` for debug logs; the default value is `0`.<br>

## Parameters

<table data-header-hidden><thead><tr><th valign="top">Parameter</th><th valign="top">Type</th><th valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><strong>Parameter</strong></td><td valign="top"><strong>Type</strong></td><td valign="top"><strong>Direction</strong></td><td valign="top"><strong>Description</strong></td></tr><tr><td valign="top"><code>JSON_CONTENT</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">Query to execute</td></tr><tr><td valign="top"><code>JSON_CONTENT_FILE</code></td><td valign="top">FILE</td><td valign="top">IN</td><td valign="top">Query to execute, stored in a file</td></tr></tbody></table>

## Parameter mapping

### Using simple parameter names

The application supports custom OUT parameters to map simple JSON content.

📌 **Example**

```json
{
    "person": {
        "address": {
            "street": "160 Guy Street",
            "zipcode": "J4G 1U4"
        },
        "age": 30,
        "name": "John"
    }
}
```

The following parameters allow you to map the JSON content to different process data:

<table data-header-hidden><thead><tr><th valign="top">Parameter</th><th valign="top">Type</th><th valign="top">Direction</th><th valign="top">Retrieve the value into a data</th><th>Result</th></tr></thead><tbody><tr><td valign="top"><strong>Parameter</strong></td><td valign="top"><strong>Type</strong></td><td valign="top"><strong>Direction</strong></td><td valign="top"><strong>Retrieve the value into a data</strong></td><td><strong>Result</strong></td></tr><tr><td valign="top"><code>person.address.street</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top"><code>DATA_STREET</code></td><td><code>160 Guy Street</code></td></tr><tr><td valign="top"><code>person.address.zipcode</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top"><code>DATA_ZIPCODE</code></td><td><code>J4G 1U4</code></td></tr><tr><td valign="top"><code>person.age</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top"><code>DATA_AGE</code></td><td><code>30</code></td></tr><tr><td valign="top"><code>person.name</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top"><code>DATA_NAME</code></td><td><code>John</code></td></tr></tbody></table>

### Using JSONPath query language

The application supports the JSONPath query language, similar to XPath expressions in XML. This language allows you to retrieve specific data from a JSON. For more details regarding the JSONPath syntax, see <https://github.com/json-path/JsonPath>.

📌 **Example**

```json
{
    "person": {
      "name": "Elizabeth",
      "age": 85,
      "dob": "1937-09-23T00:00:00Z",
      "children": [
        {
          "name": "Charles",
          "age": 60,
          "children": [
            {
              "name": "Nathalie",
              "children": [
                {
                  "name": "George",
                  "age": 8
                },
                {
                  "name": "Charlotte",
                  "age": 10
                },
                {
                  "name": "Jefferson",
                  "age": 7
                }
              ]
            },
            {
              "name": "Harry"
            }
          ]
        },
        {
          "name": "Bob",
          "age": 57,
          "children": [
            {
              "name": "John"
            },
            {
              "name": "Mark"
            }
          ]
        }
      ]
    }
}
```

In the above example, we want to get the names of Charles's grandchildren who are older than seven years old, and we also want these names to be separated by a `|` (using the `APP_JSONPATH_DELIMITER` IN parameter). At the same time, we are also getting Elizabeth's age and date of birth. To get the information, the following parameters must be defined:

<table data-header-hidden><thead><tr><th valign="top">Parameter</th><th valign="top">Type</th><th valign="top">Direction</th><th valign="top">IN Value</th><th>OUT Value</th></tr></thead><tbody><tr><td valign="top"><strong>Parameter</strong></td><td valign="top"><strong>Type</strong></td><td valign="top"><strong>Direction</strong></td><td valign="top"><strong>IN Value</strong></td><td><strong>OUT Value</strong></td></tr><tr><td valign="top"><code>APP_JSONPATH_DELIMITER</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><code>|</code></td><td></td></tr><tr><td valign="top"><code>PARAM1__JSONPATH</code></td><td valign="top">TEXT</td><td valign="top">INOUT</td><td valign="top"><code>person.children[?(@.name == 'Charles')].children[*].children[?(@.age > 7)].name</code></td><td>data <code>DATA1_VALUE</code> (value will be: <code>George|Charlotte</code>)</td></tr><tr><td valign="top"><code>AGE__JSONPATH</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><code>$.person.age</code></td><td></td></tr><tr><td valign="top"><code>AGE</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top"></td><td>data <code>AGE_VALUE</code> (value will be: <code>85</code>)</td></tr><tr><td valign="top"><code>DOB__JSONPATH</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><code>$.person.dob</code></td><td></td></tr><tr><td valign="top"><code>DOB</code></td><td valign="top">DATETIME</td><td valign="top">OUT</td><td valign="top"></td><td>data <code>DOB_VALUE</code> (value will be: <code>1937-09-23T00:00:00Z</code>)</td></tr></tbody></table>

{% hint style="warning" %}

* In the `PARAM1__JSONPATH` parameter name, the `PARAM1` name is not relevant, but it must be followed by the `__JSONPATH` suffix (**two** underscores are used in the suffix).<br>
* To retrieve a value into a **Text** process data, you can use a single INOUT Text parameter (e.g. `PARAM1__JSONPATH` parameter as in the example above).<br>
* To retrieve a value into a **Numeric** or **DateTime** process data, you **must** use separate parameters: an IN Text parameter for the JSONPath query and an OUT parameter that maps to the Numeric or DateTime process data. Both parameters must share the same name prefix (e.g. `AGE__JSONPATH` and `AGE` parameters as in the example above).<br>
* The default value of `APP_JSONPATH_DELIMITER` is a comma (`,`) when this parameter is not defined.
  {% endhint %}


---

# 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://docs.workflowgen.com/admin/workflow-applications/jsontodata-workflow-application.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.
