JSON Scalar

json_exists()

Test whether a JSON document contains a path, including paths whose stored value is JSON null.

Reference: Haybarn WASM 2.0.0-rc12

Arguments & returns

4 overloads

json_exists(json, path)

Scalar
Overload link jsonpath Returns
#01 JSONVARCHAR BOOLEAN
#02 JSONVARCHAR[] BOOLEAN[]
#03 VARCHARVARCHAR BOOLEAN
#04 VARCHARVARCHAR[] BOOLEAN[]

Check whether a JSON path exists

Test whether a JSON document contains a path, including paths whose stored value is JSON null.

An existing path returns true and an absent path returns false. SQL NULL input produces SQL NULL.

Check whether a JSON path exists
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide example · Run to view results.

Expected result
presentabsentmissing
truefalseNULL

Watch for: Existence does not mean a value is non-null. Use json_type() or extract the value when the distinction matters.

In other engines

PostgreSQLjsonb_exists()

SELECT JSONB_EXISTS('{"a": [1,2,3]}', 'a')
In Haybarn
SELECT JSON_EXISTS('{"a": [1,2,3]}', '$.a')

SQLGlot example ↗