# JSON Generator

**JSON Generator** creates a JSON object. This connector accepts any input.

## **Parameters**

Take a look at the configuration options for the connector. Parameters supported by [Double Braces expressions](https://docs.digibee.com/documentation/connectors-and-triggers/double-braces/overview) are marked with `(DB)`.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>JSON</strong> <code>(DB)</code></td><td>The JSON object that will be the output of the connector.</td><td>N/A</td><td>JSON Object</td></tr><tr><td><strong>Fail on Error</strong></td><td>If the option is activated, the pipeline's execution with an error will be interrupted. Otherwise, the pipeline execution proceeds, but the result will show a false value for the <code>"success"</code> property.</td><td>False</td><td>Boolean</td></tr></tbody></table>

## **Using Global variables**

[Global variables](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/platform-administration/settings/globals) can be retrieved in the **JSON Generator** connector using the following Double Braces expression:

```json
{{global.global-name}}
```

You can retrieve Globals in two ways:

* As a **string**
* As a **number**

### **Retrieving Global variables as a string**

If the Global variable’s value is a string, regardless of its category, you must enclose the Double Braces expression in **double quotes**.

For example, suppose you create a Global named **global-email** under the **Email** category and set an email address as its value. The Platform will interpret this value as a string. Therefore, to retrieve this Global variable in the **JSON Generator** connector, structure the expression as follows:

```json
{
    "email": "{{global.global-email}}"
}
```

If you don’t enclose the expression in double quotes, you will receive the following error:

{% code overflow="wrap" %}

```json
{
  "timestamp": 1738778741919,
  "error": "An internal error has occurred. Exception: com.digibee.pipelineengine.exception.PipelineEngineRuntimeException: Could not parse double braces parameter json due to JSON exception: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'email': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"{\n  \"email\": email@gmail.com\n}\"; line: 2, column: 17]",
  "code": 500
}
```

{% endcode %}

This rule applies to any Global variable with a **string value**.

### **Retrieving Global variables as a number**

If the Global variable’s value is a **number**, don’t enclose the Double Braces expression in double quotes. Otherwise, the number will be treated as a string.

For example, suppose you create a Global named **global-id** under the **ID** category and set its value to **1234**.

To retrieve this Global variable as a number in the **JSON Generator** connector, structure the expression as follows:

```json
{
    "id": {{global.global-id}}
}
```

The output will be:

```json
{
    "id": 1234
}
```

However, if you need to retrieve it as a **string**, simply enclose the expression in double quotes:

```json
{
    "id": "{{global.global-id}}"
}
```

This will return:

```json
{
	"id": "1234"
}
```

## **Usage example**

In this example, we used the **JSON Generator** connector to modify someone’s data. Here, we want to join the `firstName` and `lastName` properties into a single property called `fullName`. We also want to delete the phoneNumber property and add a property called country, which has the value “Brazil”.

### **Input**

```json
{
    “firstName” : “Carlos”,
    “lastName” : “Silva”,
    “phoneNumber” : “+55(11)99999-8888”
}
```

#### **Parameter settings**

We use the **JSON Generator** connector with the following JSON parameter configuration:

```json
{
    "fullName" : {{ CONCAT(message.firstName," ", message.lastName) }},
    "country" : "Brazil"
}
```

Here, we used the [CONCAT Double Braces](https://docs.digibee.com/documentation/connectors-and-triggers/double-braces/double-braces-functions/string-functions#id-8prry81brr15) function to join the first and last names, with a blank space between them.

### **Output**

```json
{
    "fullName": "Carlos Silva",
    "country": "Brazil"
}
```


---

# 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.digibee.com/documentation/connectors-and-triggers/connectors/tools/json-generator.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.
