# json_object_agg

Aggregate key/value pairs into native JSON, including NULL values and retaining duplicate keys.

**Syntax**

```text
json_object_agg(key, value [ORDER BY ...]) [FILTER (WHERE ...)]
```

**Arguments**

Scalar non-NULL keys and SQL values; DISTINCT, FILTER, ordering, and ordinary windows are supported.

**Returned value**

Native JSON object; empty input returns NULL.

**Examples**

```sql
CREATE TABLE attributes (name TEXT, value INTEGER);
INSERT INTO attributes VALUES ('a',1),('b',NULL);
```

```sql
SELECT json_object_agg(name,value) FROM attributes FORMAT csv;
```

```text
"{""a"":1,""b"":null}"
```
