Categories: Variant Type
TRY_PARSE_JSON Preview
Parses a JSON string into a VARIANT value, returning NULL if the JSON is invalid.
Syntax
TRY_PARSE_JSON(json_string VARCHAR) → VARIANT
- json_string: A string containing JSON.
Examples
TRY_PARSE_JSON exampleSELECT TRY_PARSE_JSON('{"name": "Alice"}')
-- (VARIANT) {"name":"Alice"}
SELECT TRY_PARSE_JSON('not valid json')
-- NULL
Usage Notes
TRY_PARSE_JSON behaves identically to PARSE_JSON, except that it returns NULL instead of raising an error when the input is not valid JSON.
Use TRY_PARSE_JSON when processing data that may contain malformed JSON and you want to handle errors gracefully.
For details on how JSON types are mapped to VARIANT internal types, see PARSE_JSON.