On Sun, Oct 4, 2026 at 5:16 AM PG Bug reporting form <
noreply@postgresql.org> wrote:
> The documented syntax makes the key/value pair list optional and says that
> an
> empty pair list constructs an empty object. However, adding any of the
> optional
> clauses without a pair causes a syntax error.
>
> **Reproduction:**
>
> ```sql
> SELECT JSON_OBJECT(); -- returns {}
> SELECT JSON_OBJECT(NULL ON NULL); -- syntax error, SQLSTATE 42601
JSON_ARRAY seems have the same situation.
The attached doc patch can this JSON_OBJECT doc issue.
the idea is to make json_object have 2 entries:
json_object ( { key_expression { VALUE | ':' } value_expression [ FORMAT JSON [ ENCODING UTF8 ] ] }[, ...] [ { NULL | ABSENT } ON NULL ] [ { WITH | WITHOUT } UNIQUE [ KEYS ] ] [ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ])
json_object ( [ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ])
It feels ugly with too much text crammed together; perhaps we need another way to solve this problem.
--
jian
https://www.enterprisedb.com/