---
schema_version: "1"
id: d0ef78b84cf08fb47dedff5e8fde423c09c60b9d8c908c7bb04de9e729b4973c
title: JSON Functions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/json-func/json-funcs.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-funcs.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8351735ded4fd743d753af4e0051d85361eafa60c338e174890a3df9eb4c0b23
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# JSON Functions

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Hyper supports the SQL:2016 functions for constructing [JSON](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/json.md) values from SQL data. Use JSON functions to:

- **Build JSON arrays** from a list of values.
- **Build JSON objects** from key-value pairs.
- **Convert any scalar value** to its JSON representation.
- **Parse and embed** pre-formatted JSON documents.

## Construction

Build JSON values from SQL data:

- `[json](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-constructor.md)` - Parse a string into a JSON value.
- `[json_array](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-array.md)` - Build a JSON array from a list of values.
- `[json_object](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-object.md)` - Build a JSON object from key-value pairs.
- `[json_scalar](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-scalar.md)` - Convert any scalar value to JSON.

### Considerations

- Strings passed as arguments are escaped and become JSON string values. To embed a value as raw JSON instead, pass a `json`-typed value or use the `FORMAT JSON` modifier.
- The `RETURNING` clause and the `WITH UNIQUE KEYS` option from the SQL:2016 standard aren't supported.



## Examples



### Build a Nested Customer Summary

Combine `json_object` and `json_array` to build a nested document from table columns.

```sql
SELECT json_object(
  'id': c.id,
  'name': c.name,
  'phone_numbers': json_array(
    c.home_phone,
    c.work_phone,
    c.mobile_phone
    ABSENT ON NULL
  )
) AS customer_summary
FROM customers c;
```

Returns `{"id":42,"name":"Alfons","phone_numbers":["(415) 555-0134"]}` for a customer with only a mobile number on file.

### Embed Pre-Formatted JSON

Use the `json` constructor to embed an existing JSON document without escaping it.

```sql
SELECT json_object('a': 1, 'b': json('{"nested":true}')) AS result;
```

Returns `{"a":1,"b":{"nested":true}}`.

## Related Documentation

- [JSON Type](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/json.md)
- [JSON_ARRAYAGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/aggregate-func/json-arrayagg.md) - Aggregate values from a group into a JSON array.
- [Array Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/array-func/arrays.md)

