---
title: json_tuple table-valued generator function
description: Learn the syntax of the json\_tuple function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/json_tuple
---

# `json_tuple` table-valued generator function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns multiple JSON objects as a tuple.

## Syntax

```
json_tuple(jsonStr, path1 [, ...] )
```

## Arguments

* `jsonStr`: A `STRING` expression with well-formed JSON.
* `pathN`: A `STRING` literal with a [JSON path expression](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-json-path-expression.md).

## Returns

A single row composed of the JSON objects.

If any object cannot be found, `NULL` is returned for that object.

* **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.1 and earlier:

  `json_tuple` can only be placed in the `SELECT` list as the root of an expression or following a [LATERAL VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-lateral-view.md).
  When placing the function in the `SELECT` list there must be no other generator function in the same `SELECT` list or [UNSUPPORTED\_GENERATOR.MULTI\_GENERATOR](https://docs.databricks.com/aws/en/error-messages/unsupported-generator-error-class.md#multi_generator) is raised.

* **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above:

  Invocation from the [LATERAL VIEW clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-lateral-view.md) or the `SELECT` list is deprecated.
  Instead, invoke `json_tuple` as a [table\_reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-table-reference.md).

## Examples

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.1 and earlier:

```sql
> SELECT json_tuple('{"a":1, "b":2}', 'a', 'b'), 'Spark SQL';
 1  2  Spark SQL

> SELECT json_tuple('{"a":1, "b":2}', 'a', 'c'), 'Spark SQL';
 1  NULL  Spark SQL

> SELECT json_tuple('{"a":1, "b":2}', 'a', 'c'), json_tuple('{"c":1, "d":2}', 'c', 'd'), 'Spark SQL';
 Error: UNSUPPORTED_GENERATOR.MULTI_GENERATOR
```

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above:

```sql
> SELECT j.*, 'Spark SQL' FROM json_tuple('{"a":1, "b":2}', 'a', 'b') AS j;
 1  2  Spark SQL

> SELECT j.*, 'Spark SQL' FROM json_tuple('{"a":1, "b":2}', 'a', 'c') AS j;
 1  NULL  Spark SQL

> SELECT j1.*, j2.*, 'Spark SQL'
 FROM json_tuple('{"a":1, "b":2}', 'a', 'c') AS j1,
      json_tuple('{"c":1, "d":2}', 'c', 'd') AS j2;
```

## Related functions

* [: operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/colonsign.md)
* [`json_object_keys` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/json_object_keys.md)
* [`json_array_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/json_array_length.md)
* [`json_tuple` table-valued generator function](https://docs.databricks.com/aws/en/sql/language-manual/functions/json_tuple.md#)
* [`from_json` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/from_json.md)
* [`get_json_object` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/get_json_object.md)
* [`schema_of_json` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/schema_of_json.md)
* [`to_json` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/to_json.md)
