# JSONTORANGE

#### Syntax

**JSONTORANGE**(*values*, *keys*)

1. *json* - a text in json format, from which the content is extracted as a range - ***Value type**: text*

#### Remarks

* In the result range, only the top 1-2 levels of the json string are converted to cell content
* Lower level content (level 3-n) is preserved as sub-json strings in the cells of the result range. This sub-json can be then extracted by subsequent calls of the JSONTORANGE function

#### Examples

**Example 1**: The json text contains a single json object. Only the values are returned in the result range.

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FjAri7zB3v9WLEEeoGM4s%2Fimage.png?alt=media&#x26;token=647394e6-e1df-43fd-a757-5868346c111a" alt=""><figcaption></figcaption></figure>

**Example 2** - The json contains multiple objects. They are returned as rows of the result range.&#x20;

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2F8RS73GYTzQmkUYBIwpVW%2Fimage.png?alt=media&#x26;token=71b4a9c6-f36d-4168-b114-7d2f8af27194" alt=""><figcaption></figcaption></figure>

**Example 3** - The json contains an array with values. Each element of the array is added as a new row in the result range.&#x20;

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2Frz3KV52KBCRZbYeyeLDA%2Fimage.png?alt=media&#x26;token=878410f6-53a9-47df-aa1f-65825905c6c0" alt=""><figcaption></figcaption></figure>

**Example 4** - The json contains an array nested in an array. In this case, the elements of the inner array are returned in one row in the result range.&#x20;

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FaiEesWpBqgvHjM5TIlRM%2Fimage.png?alt=media&#x26;token=cb306de4-cd6a-4bbd-8b08-79be1765e52d" alt=""><figcaption></figcaption></figure>

**Example 5** - The json contains multiple arrays nested in an array. The elements of each inner array are returned as separate rows in the result range.&#x20;

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FpsfCtyC9mz1O1RJy95m1%2Fimage.png?alt=media&#x26;token=6c26757e-5ae6-467b-8958-464d2fa46280" alt=""><figcaption></figcaption></figure>

**Example 6** - The json contains two arrays and an object nested in an array. The elements of both arrays and the object are returned as separate rows in the result range.&#x20;

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FsHffMpaIHDJW3GSBQ1Tw%2Fimage.png?alt=media&#x26;token=cd59422a-48f8-4ff2-a740-6b77d5acdfa3" alt=""><figcaption></figcaption></figure>

**Example 7** - If the json contains a structure with more than 2 levels, it is possible to extract the content of lower-level values by subsequent calls of the JSONTORANGE function.

<figure><img src="https://3862539772-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4X6nN2wTlDsVpd8P1WDM%2Fuploads%2FPDHJGTKFc6LUbPUFmwzs%2Fimage.png?alt=media&#x26;token=74ff6f10-83e9-4db4-85f7-8b3ae6927ce3" alt=""><figcaption></figcaption></figure>
