BigQuery reference
BigQuery JSON functions
BigQuery reads JSON stored as STRING or as the native JSON type. JSON_VALUE and JSON_QUERY are the standard way to extract values; the older JSON_EXTRACT family still works but treats paths differently.
Functions in this category
| Function | What it does |
|---|---|
| JSON_EXTRACT | JSON_EXTRACT(json, json_path) returns the JSON at a path (an object, an array or a quoted string) as JSON-formatted text, or as JSON for JSON input. |
| JSON_EXTRACT_ARRAY | JSON_EXTRACT_ARRAY(json[, json_path]) converts a JSON array into a SQL ARRAY with one element per item, as JSON-formatted strings (or JSON values for JSON input), ready for UNNEST. |
| JSON_EXTRACT_SCALAR | JSON_EXTRACT_SCALAR(json, json_path) returns a scalar JSON value (string, number or boolean) as a SQL STRING without quotes, and NULL for objects, arrays and JSON null. |
| JSON_KEYS | JSON_KEYS(json[, max_depth][, mode => ...]) returns the unique keys of a JSON value as a sorted ARRAY<STRING>, with nested keys as dotted paths such as user.id. |
| JSON_QUERY | JSON_QUERY(json, json_path) returns the JSON value at a path (object, array or scalar) as JSON text for STRING input or as JSON for JSON input, keeping quotes on strings. |
| JSON_QUERY_ARRAY | JSON_QUERY_ARRAY(json[, json_path]) turns a JSON array into a SQL ARRAY with one element per item: ARRAY<JSON> for JSON input, JSON-formatted strings for STRING input. |
| JSON_REMOVE | JSON_REMOVE(json, path[, path ...]) returns a copy of a JSON value with the data at each JSONPath removed, whether an object key or an array element. |
| JSON_SET | JSON_SET(json, path, value[, path, value ...]) returns a copy of a JSON value with values inserted or replaced at the given JSONPaths, creating missing parents along the way. |
| JSON_TYPE | JSON_TYPE(json) returns the type of a JSON value as a string: object, array, string, number, boolean or null. |
| JSON_VALUE | JSON_VALUE(json[, json_path]) extracts a scalar (string, number or boolean) from JSON and returns it as a SQL STRING without quotes; objects, arrays and JSON null return NULL. |
| JSON_VALUE_ARRAY | JSON_VALUE_ARRAY(json[, json_path]) extracts a JSON array of scalars as an ARRAY<STRING> with the quotes removed. |
| PARSE_JSON | PARSE_JSON(json_string) converts JSON-formatted text into a value of the JSON type, validating it on the way. |
| TO_JSON | TO_JSON(value) converts a SQL value (scalar, struct, array or whole row) into a value of the JSON type. |
| TO_JSON_STRING | TO_JSON_STRING(value[, pretty_print]) serializes any SQL value, from a scalar to a struct, an array or a whole row, into JSON text. |
More of the BigQuery reference
Date functionsDatetime functionsTimestamp functionsString functionsAggregate functionsWindow functionsArray functionsConversion functionsConditional expressionsMathematical functionsHash and utility functionsQuery syntaxDDL statementsDML statementsScripting and data movementINFORMATION_SCHEMAError messagesBigQuery pricingPricing calculator
