Invalid JSON can interrupt a query that expects structured input. Validate incoming text before passing it into extraction functions.
Worked example
SELECT json_valid('{bad}') AS valid;Result
[
{
"valid": 0
}
]Implementation notes
A valid JSON value can be a scalar. If the downstream query expects an array, inspect its type as well as its syntax.
Try it yourself
Compare malformed text, an empty object and a valid JSON null.
Open the SQL example →Editorial date February 10, 2026 · Published December 6, 2026