jsonb_set_lax()

If new_value is not NULL, behaves identically to jsonb_set. Otherwise behaves according to the value of null_value_treatment which must be one of 'raise_exception', 'use_json_null', 'delete_key', or 'return_target'. The default is 'use_json_null'.

Signature

jsonb_set_lax ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean [, null_value_treatment text ]] ) → jsonb

Examples

SELECT jsonb_set_lax('[{"f1":1,"f2":null},2,null,3]', '{0,f1}', null);
[{"f1": null, "f2": null}, 2, null, 3]
SELECT jsonb_set_lax('[{"f1":99,"f2":null},2]', '{0,f3}', null, true, 'return_target');
[{"f1": 99, "f2": null}, 2]

Run against PostgreSQL 18.6 on 2026-09-13. This is the output we got, not the documentation’s.

Want to run this against your own PostgreSQL server from an iPhone, iPad or Mac? These are ours — every connection goes straight from the device to your database, with no account and no server of ours in between.

Signature and description adapted from the PostgreSQL manual, used under the PostgreSQL License. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. This page is not affiliated with the PostgreSQL Global Development Group.