# 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://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-0252736418c2ee1381d68cbc5b4ff1eaca61b4c9%2Fimage%20(9).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-a9ed70b92066296dee4b51f6091a9287a1ad248b%2Fimage%20(10).png?alt=media" 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.

<figure><img src="https://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-47e8c6f8dc4d8e98da383578421bab20e854812b%2Fimage%20(11).png?alt=media" 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.

<figure><img src="https://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-591ec784a2cc435739943205f9e19197cf266fee%2Fimage%20(12).png?alt=media" 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.

<figure><img src="https://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-238580a365a5173fd88d4cfce47adf38d968bcf4%2Fimage%20(13).png?alt=media" 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.

<figure><img src="https://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-1da77a58497ec9456e4401e8088f1b14843d5b72%2Fimage%20(14).png?alt=media" 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://3148043601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL43fiRbeRtPnTjMpbGNO%2Fuploads%2Fgit-blob-49b2468a222ddbdfa775e83442b580d9ca817340%2Fimage%20(15).png?alt=media" alt=""><figcaption></figcaption></figure>
