> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Calculates a list of distinct paths stored in a JSON column.

# distinctJSONPaths

<h2 id="distinctJSONPaths">
  distinctJSONPaths
</h2>

Introduced in: v24.9.0

Calculates a list of distinct paths stored in a [JSON](/reference/data-types/newjson) column.

**Syntax**

```sql theme={null}
distinctJSONPaths(json)
```

**Arguments**

* `json` — JSON column. [`JSON`](/reference/data-types/newjson)

**Returned value**

Returns the sorted list of paths. [`Array(String)`](/reference/data-types/array)

**Examples**

**Basic usage with nested JSON**

```sql title=Query theme={null}
DROP TABLE IF EXISTS test_json;
CREATE TABLE test_json(json JSON) ENGINE = Memory;
INSERT INTO test_json VALUES ('{"a" : 42, "b" : "Hello"}'), ('{"b" : [1, 2, 3], "c" : {"d" : {"e" : "2020-01-01"}}}'), ('{"a" : 43, "c" : {"d" : {"f" : [{"g" : 42}]}}}');

SELECT distinctJSONPaths(json) FROM test_json;
```

```response title=Response theme={null}
┌─distinctJSONPaths(json)───┐
│ ['a','b','c.d.e','c.d.f'] │
└───────────────────────────┘
```

**With declared JSON paths**

```sql title=Query theme={null}
DROP TABLE IF EXISTS test_json;
CREATE TABLE test_json(json JSON) ENGINE = Memory;
INSERT INTO test_json VALUES ('{"a" : 42, "b" : "Hello"}'), ('{"b" : [1, 2, 3], "c" : {"d" : {"e" : "2020-01-01"}}}'), ('{"a" : 43, "c" : {"d" : {"f" : [{"g" : 42}]}}}')

SELECT distinctJSONPaths(json) FROM test_json;
```

```response title=Response theme={null}
┌─distinctJSONPaths(json)─┐
│ ['a','b','c']           │
└─────────────────────────┘
```
