JSON Scalar

json_extract_string()

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

Reference: Haybarn WASM 2.0.0-rc12

Arguments & returns

6 overloads

json_extract_string(json, index)

Scalar
Overload link jsonindex Returns
#01 JSONBIGINT VARCHAR
#02 VARCHARBIGINT VARCHAR

json_extract_string(json, path)

Scalar
Overload link jsonpath Returns
#03 JSONVARCHAR VARCHAR
#04 JSONVARCHAR[] VARCHAR[]
#05 VARCHARVARCHAR VARCHAR
#06 VARCHARVARCHAR[] VARCHAR[]

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.

In a query

Find the value inside the document.

Extract a JSON field directly as text, ready to use in the rest of your query.

Find the value inside the document.
SQL
Haybarn WASM 2.0.0-rc12 · In your browser

Guide recipe · Run to view results.