Skip to content

json_agg_strict ​

Collect rows into a native JSON array.

Syntax

text
json_agg_strict(value)

Arguments

One SQL value per row. Skip SQL NULL values; retain a JSON null value. Plain JSON preserves object input order and nested duplicates. Tuple values use named/fN fields. FILTER, DISTINCT, aggregate ordering, and ordinary windows apply.

Returned value

Native JSON. No input rows returns SQL NULL; rows containing only skipped SQL NULL values produce an empty container.

Examples

sql
CREATE TABLE readings (value INTEGER);
INSERT INTO readings VALUES (1),(NULL),(2);
sql
SELECT json_agg_strict(value) FROM readings FORMAT csv;
text
"[1,2]"