> For the complete documentation index, see [llms.txt](https://docs.nedyx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nedyx.com/version-1.52-preview/clearlines-functions/range-functions/rangetojson.md).

# RANGETOJSON

Converts a range of cells to a json text.

#### 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://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2F52QaTGX4t99J6alaNTDI%2Fimage.png?alt=media&amp;token=269824e3-3616-4d8f-a8f6-b8a02910a531" 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://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FqpS05QckpMtx4Db7Flf3%2Fimage.png?alt=media&amp;token=5eb1224b-4c15-40fa-8575-116a0e7b04f5" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FaqJPhqpWJHYOLO7wJWUh%2Fimage.png?alt=media&amp;token=cafc00b9-be3b-4cae-b859-1671a6185590" 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://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FVTM85pfyzBczNMgHZsHH%2Fimage.png?alt=media&amp;token=471c096a-bf64-4617-8802-5268e17fcc9e" 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://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FyTMsvP4rpbOrEdyRwaNG%2Fimage.png?alt=media&amp;token=51773c3c-7e94-435a-8ca6-eb4864345a80" alt=""><figcaption></figcaption></figure>
