JSON Functions
On this page
SingleStore provides functions and operators for creating, querying, searching, modifying, and formatting JSON values.
The following sections categorize JSON functions by their primary use case.
Creation Functions
|
Function |
Description |
Example |
|---|---|---|
|
|
Converts a SQL value to JSON. |
|
|
|
Converts an entire row into a JSON object. |
|
|
|
Creates a JSON object from key-value pairs. |
|
|
|
Creates a JSON array from the specified values. |
|
|
|
Aggregates an entire row into a JSON array of JSON objects. |
|
|
|
Aggregates values into a JSON array. |
|
Extraction Functions
|
Function |
Description |
Example |
|---|---|---|
|
|
Extracts a JSON value and returns JSON. |
|
|
|
Extracts a JSON value and returns an unquoted SQL string. |
|
|
|
Extracts a JSON value and returns a SQL |
|
|
|
Extracts a JSON value and returns a SQL |
|
|
|
Returns the top-level keys as a JSON array. |
|
|
|
Returns the JSON type of the value. |
|
|
|
Returns only the keys specified by the mask. |
|
|
|
Returns all keys except those specified by the mask. |
|
|
|
Returns the number of elements in an array or keys in an object. |
|
Note
The JSON shorthand extraction operators (::, ::$, and ::%) and the JSON_ functions support key paths that can reference values in both JSON objects and arrays.
Search Functions
|
Function |
Description |
Example |
|---|---|---|
|
|
Returns the matching element if any array element matches the predicate. |
|
|
|
Returns 1 if a value exists at the specified path. |
|
|
|
Returns 1 if the array contains the specified JSON value. |
|
|
|
Returns 1 if the array contains the specified string. |
|
|
|
Returns 1 if the array contains the specified numeric value. |
|
Modification Functions
|
Function |
Description |
Example |
|---|---|---|
|
|
Sets or updates a key with a JSON value. |
|
|
|
Sets or updates a key with a string value. |
|
|
|
Sets or updates a key with a numeric value. |
|
|
|
Removes a key from a JSON object. |
|
|
|
Appends a value to a JSON array. |
|
|
|
Appends a value to a |
|
|
|
Appends a value to a string value. |
|
|
|
Removes and inserts array elements at a specified position. |
|
|
|
Removes and inserts array elements at a specified position. |
|
|
|
Removes and inserts array elements at a specified position. |
|
|
|
Merges JSON objects according to RFC 7396. |
|
Formatting and Conversion Functions
|
Function |
Description |
Example |
|---|---|---|
|
|
Returns formatted JSON as a human-readable string. |
|
|
|
Converts a JSON array to a SingleStore |
|
Array Aggregation and Reduction
|
Function |
Description |
Example |
|---|---|---|
|
|
Applies a lambda function cumulatively to array elements. |
|
|
|
Converts a SingleStore |
|
Index JSON Columns
|
Index |
Description |
Example |
|---|---|---|
|
Indexes values in JSON arrays or nested paths for fast equality lookups. |
| |
|
Enables full-text search on JSON columns, with fuzzy matching, regular expressions, and per-key searches. |
| |
|
Extracts a scalar value from a non-array JSON path into a persisted computed column and creates a hash index for fast equality lookups. |
| |
|
Extracts a value from JSON into a persisted column and enforces uniqueness with a unique index. |
| |
|
Extracts a text value from JSON into a persisted column and creates a full-text index on that field. |
| |
|
Extracts a vector embedding from JSON into a persisted column and creates a vector index for approximate nearest neighbor (ANN) search. |
|
Keypath Syntax Reference
|
Syntax |
Returns |
Description |
|---|---|---|
|
|
|
Extracts a key as a JSON value. |
|
|
|
Extracts a key as an unquoted string. |
|
|
|
Extracts a key as a numeric value. |
|
|
|
Navigates nested keys. |
|
|
|
Extracts an array element by index. |
|
|
|
Chains nested object and array access. |
Related Topics
In this section
Last modified: