Dev Helpers

SQL / JSON construction

Construct an array

Dev Helpers · March 26, 2026

A JSON array preserves element order and type. Inspect the distinction between a nested JSON value and a string containing JSON text.

Worked example

SELECT json_array(1,'build',NULL) AS payload;

Result

[
  {
    "payload": "[1,\"build\",null]"
  }
]

Implementation notes

Constructors treat ordinary text differently from a value returned by a JSON function. Parse nested structures deliberately before embedding them.

Try it yourself

Include a number, a string and a null in the same array.

Open the SQL example →

Editorial date March 26, 2026 · Published December 6, 2026

Related articles

Replace the middle coordinate

Replacing a JSON array element requires an existing path. A missing coordinate calls for a separate insert or set policy.

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.