TRY_JSON_PARSE()

All functions > JSON > TRY_JSON_PARSE()

Returns the given string as a JSON expression, or NULL if the string is not valid JSON.

Signatures

Returns: A JSON value parsed from the string, or NULL on invalid input

TRY_JSON_PARSE(expr: VARCHAR) → JSON
sql
ParameterTypeRequiredDescription
exprVARCHARYesThe JSON string to parse

Notes

  • Same as JSON_PARSE but returns NULL instead of raising an error on invalid input
  • Follows the TRY_CAST pattern: graceful failure instead of exceptions
  • Useful for safely parsing user input or unvalidated data
  • Accepts valid JSON format strings
  • Supports objects, arrays, and primitives
  • Use JSON_EXTRACT after parsing to access nested values

See also

Examples

Edge cases

FeatureQL
SELECT
    f1 := TRY_JSON_PARSE('{"name": "Alice"}'), -- Valid JSON parses normally
    f2 := TRY_JSON_PARSE('[1, 2, 3]') -- Valid JSON array
;
Result
f1 VARCHARf2 VARCHAR
{"name": "Alice"}[1, 2, 3]

Last update at: 2026/05/26 17:22:09