jsonb_extend
Merge two or more jsonb values
jsonb-extend · Merge two or more jsonb values
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100593 | jsonb_extend | jsonb-extend | 1.0 | FUNC | MIT | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
jsonb_extend 1.0 provides shallow and recursive JSONB merging. It is useful when merge order must be explicit: later object values replace earlier values, while arrays are concatenated. The source targets old PostgreSQL internals, so build and test it against the exact server major you operate.
Core Workflow
Function Index
jsonb_extend(variadic jsonb[])performs a shallow merge. An object must be followed only by objects; an initial array accepts later arrays, objects, or scalars.jsonb_deep_extend(boolean, variadic jsonb[])accepts objects and recursively merges nested objects when the flag is false. A true flag treats nested values atomically instead of descending into them.- Both functions are declared immutable and strict. A single input is returned unchanged; incompatible shapes raise an error.
Caveats
- Merge order is significant, and replacement is not the same as RFC JSON Merge Patch semantics.
- The implementation was written against PostgreSQL 9.4-era JSONB internals. A successful source build on one major is not compatibility evidence for another.
- Review output sizes before merging large arrays or deeply nested objects; the operation constructs a new JSONB value.