Dev Helpers

SQL / JSON extraction

Validate an incoming JSON string

Dev Helpers · February 10, 2026

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

Related articles

Compare two literal lists

Set operations compare rows under SQL's rules for duplicates. Check whether the result represents membership or the number of occurrences.

Count jobs per active day

Grouping timestamps by day produces counts only for days present in the data. A continuous chart may need a calendar series as well.