# RANGETOJSON

#### Syntax

**RANGETOJSON**(*values*, *keys*)

1. *values* - the values which should be added to the json string - ***Value type**: any*
2. *keys* - the keys which are added to the json string - ***Value type**: text (optional)*

#### Remarks

* The json string is created in the following way:
  * If *keys* is specified, *values* are packaged as **key-value pairs** into the json string in the following way:
    * if *values* contains only one row, the json string consists on one object, including the key-value pairs of *keys* and their corresponding *values*.
    * if values contains multiple row, the json string consists on an array with one object per row, including the key-value pairs of *keys* and their corresponding *values (in the same way as above)*.
  * If *keys* is not specified, *values* are packaged as **array elements** into the json string, in the following way:
    * every row of values is added as an element of the array
    * if a row contains more than one cell, every cell content of the row is added as an element to a sub-array to the outer array

#### Examples

**Example 1**: The content of the *#keys* and *#values* widgets are used to create a json object string.

<figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-4cb6fbab1764db2ffb0be0fca728520b6a7b1f8c%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Example 2**: The same as example 1, but the *#values* widget contains now multiple rows. Every row is then added as a separate object in the json string.

<figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-d33ebb4dd543fd335423a065a5989fa45fe586ad%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Example 3:** If no keys are specified, only the #values is added in the json string.

<figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-8a8681b77ddb36648de51c750ea84f84cedb688f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Example 4**: This structure can be used to create a json string with only one array, containing values.

<figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-64713b953a3554434ab17427d4dd1580e97eb30a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Example 5**: Same as example 3, but with multiple lines in #values. This returns then a json string containing a nested array of values.

<figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-bc1546f05c64e63c2e6d1d2932059bc1343a4ab3%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
