JSON support in Spice is based on datafusion-functions-json, which provides functions and operators to extract, query, and manipulate JSON data stored as strings. Advanced features for JSON creation, modification, or complex path expressions are not supported.
Enables extracting and manipulating data from JSON strings. Each function takes a JSON string as the first argument, followed by one or more keys or indices to specify the path.
json_containsReturns true if a JSON string contains a specific key at the specified path.
json_getRetrieves a value from a JSON string based on its path.
json_get_strRetrieves a string value from a JSON string based on its path.
json_get_intRetrieves an integer value from a JSON string based on its path.
json_get_floatRetrieves a float value from a JSON string based on its path.
json_get_boolRetrieves a boolean value from a JSON string based on its path.
json_get_jsonRetrieves a nested JSON object or array as a raw JSON string from a JSON string based on its path.
json_get_arrayRetrieves an arrow array from a JSON string based on its path.
json_as_textRetrieves any value from a JSON string based on its path and represents it as a string. This is useful for converting JSON values to text format.
json_lengthReturns the length of a JSON string, array, or object. For objects, returns the number of key-value pairs. For arrays, returns the number of elements. For strings, returns the character count.
-> {#op_json_get}JSON access operator. Retrieves a value from a JSON string based on its path. This operator is an alias for json_get.
->> {#op_json_as_text}JSON access operator for text extraction. Retrieves any value from a JSON string and converts it to text. This operator is an alias for json_as_text.
? {#op_json_contains}JSON containment operator. Returns true if a JSON string contains the specified key. This operator is an alias for json_contains.
JSON functions can be used in views to simplify access to nested JSON data: