SQL JSON extraction and path functions

Query JSON fields in Haybarn SQL, extract plain text, and distinguish missing paths from JSON null values.

Choose a function

Choose the result type first. Use json_extract() to keep a JSON value, json_extract_string() for text, and a subsequent cast for a typed number or date. Use json_exists() when only the presence of a field matters.

A missing path and a field containing JSON null are different cases. JSON arrays use zero-based positions. Invalid JSON can raise an error before extraction, so validate untrusted text with json_valid().

Extract JSON fields as text

Read a JSON field as VARCHAR without JSON string quotes, ready for text filtering, display, or a subsequent type conversion.

A missing path or a JSON null at the path produces SQL NULL.

Extract JSON fields as text
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide example · Run to view results.

Expected result
namepricemissing
apple12NULL

Watch for: The result is text even when the JSON value is numeric. Cast it before arithmetic, and use TRY_CAST if malformed values should become NULL.

Full json_extract_string() reference →

All json functions

56 functions in Haybarn WASM 2.0.0-rc12. Browse the filtered catalog →