Skip to content

jsonb_object_agg_strict ​

Collect rows into a native JSON object.

Syntax

text
jsonb_object_agg_strict(key,value)

Arguments

Scalar non-NULL keys and native values. Skip SQL NULL values; retain a JSON null value. JSONB forms recursively normalize keys and final values. 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 attributes (name TEXT, value INTEGER);
INSERT INTO attributes VALUES ('a',1),('b',NULL);
sql
SELECT jsonb_object_agg_strict(name,value) FROM attributes FORMAT csv;
text
"{""a"":1}"