Skip to main content

JSON Functions

This section provides reference information for JSON functions in Databend. JSON functions enable parsing, validation, querying, and manipulation of JSON data structures.

JSON Parsing & Validation

FunctionDescriptionExample
PARSE_JSONParses a JSON string into a variant valuePARSE_JSON('{"name":"John","age":30}'){"name":"John","age":30}
CHECK_JSONValidates if a string is valid JSONCHECK_JSON('{"valid": true}')true

JSON Type Information

FunctionDescriptionExample
JSON_TYPEOFReturns the type of a JSON valueJSON_TYPEOF('{"key": "value"}')'OBJECT'

JSON Conversion

FunctionDescriptionExample
JSON_TO_STRINGConverts a JSON value to a stringJSON_TO_STRING({"name":"John"})'{"name":"John"}'

JSON Path Operations

FunctionDescriptionExample
JSON_PATH_EXISTSChecks if a JSON path existsJSON_PATH_EXISTS('{"a":1}', '$.a')true
JSON_PATH_MATCHMatches JSON values against a path patternJSON_PATH_MATCH('{"items":[1,2,3]}', '$.items[*]')[1,2,3]
JSON_PATH_QUERYQueries JSON data using JSONPathJSON_PATH_QUERY('{"a":1,"b":2}', '$.a')1
JSON_PATH_QUERY_ARRAYQueries JSON data and returns results as an arrayJSON_PATH_QUERY_ARRAY('[1,2,3]', '$[*]')[1,2,3]
JSON_PATH_QUERY_FIRSTReturns the first result from a JSON path queryJSON_PATH_QUERY_FIRST('[1,2,3]', '$[*]')1

JSON Data Extraction

FunctionDescriptionExample
JSON_EXTRACT_PATH_TEXTExtracts text value from JSON using pathJSON_EXTRACT_PATH_TEXT('{"name":"John"}', 'name')'John'
JSON_EACHExpands JSON object into key-value pairsJSON_EACH('{"a":1,"b":2}')[("a",1),("b",2)]
JSON_ARRAY_ELEMENTSExpands JSON array into individual elementsJSON_ARRAY_ELEMENTS('[1,2,3]')1, 2, 3

JSON Formatting & Processing

FunctionDescriptionExample
JSON_PRETTYFormats JSON with proper indentationJSON_PRETTY('{"a":1}') → Formatted JSON string
STRIP_NULL_VALUERemoves null values from JSONSTRIP_NULL_VALUE('{"a":1,"b":null}'){"a":1}
JQProcesses JSON using jq-style queriesJQ('{"name":"John"}', '.name')"John"