Documentation Index
Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
Use this file to discover all available pages before exploring further.
JSON Functions Operating on JSON Data
These JSON functions provide means to process JSON documents stored in nativeJSON columns. This should be preferred over storing JSON data in TEXT columns.
- These operators extract a field from a JSON value, returing another JSON value:
- Dot Operator (
.) - Subscript Operator (
[])
- Dot Operator (
- These functions convert a JSON value to a SQL value:
- These functions convert a SQL value to a JSON value:
JSON Functions Operating on TEXT Data
These JSON functions provide means to process JSON documents stored inTEXT columns.
There are three types of JSON functions for extracting values:
- These functions extract part of the document, but preserve the original data in the result:
- These functions convert a JSON value to a SQL value:
- This function extracts a JSON value and converts it to a SQL value, combining the functionalities of the previous two types of functions:
JSON_POINTER_EXTRACT to extract a value from a JSON document and JSON_VALUE to convert it into a SQL value:
val1 as a SQL TEXT value, rather than the original JSON value "val1" with the double quotes.
The JSON_FORMAT function can be used to format JSON documents, including pretty-printing and minifying documents.
Currently, JSON functions support only JSON pointer expressions, which provide a method for accessing specific elements within a JSON document.
For convenience, the following aliases are available for JSON functions that use JSON pointer expressions:
JSON_POINTER_EXTRACTis an alias forJSON_EXTRACTwith thepath_syntaxparameter set to'JSONPointer'.JSON_POINTER_EXTRACT_ARRAYis an alias forJSON_EXTRACT_ARRAYwith thepath_syntaxparameter set to'JSONPointer'.
JSON pointer expression syntax
The placeholder<json_pointer_expression> indicates where you should use a JSON pointer, which allows access to specific elements in a JSON document. For a formal specification, see RFC6901.
A JSON pointer begins with a forward slash (/), indicating the root of the JSON document, followed by a sequence of property (key) names or zero-based ordinal numbers separated by slashes. Property names identify specific keys, while index numbers specify the Nth element in an array or object.
The tilde (~) and forward slash (/) characters have special meanings and need to be escaped as follows:
- To specify a literal tilde (
~), use~0. - To specify a literal forward slash (
/), use~1.
| Pointer | Result | Notes |
|---|---|---|
/ | { "key": 123, "key~with~tilde": 2, "key/with/slash": 3, "value": { "dyid": 987, "keywords" : ["insanely","fast","analytics"] } | Returns the whole document. |
/key | 123 | |
/key~0with~0tilde | 2 | Indicates the value associated with the key~with~tilde property name. |
/key~1with~1slash | 3 | Indicates the value associated with the key/with/slash property name. |
/0 | 123 | Uses an ordinal to indicate the value associated with the key property name. The key property is in the first 0-based position. |
/value/keywords/2 | analytics | Indicates the element “analytics”, which is in the third 0-based position of the array value associated with the keywords property. |
JSON common example
The following JSON document, represented by the<json_common_example> placeholder, is used as a basis for all JSON function examples in this reference.