json_object_agg_strict
Collect rows into a native JSON object.
Syntax
text
json_object_agg_strict(key,value)Arguments
Scalar non-NULL keys and native values. 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 attributes (name TEXT, value INTEGER);
INSERT INTO attributes VALUES ('a',1),('b',NULL);sql
SELECT json_object_agg_strict(name,value) FROM attributes FORMAT csv;text
"{""a"":1}"