SQLite 3 reference · JSON Functions
SQLite JSON_PATCH() Function
Merge one JSON object into another using RFC 7396 MergePatch: keys are added or replaced, null removes a key.
SQLite 3 Since 3.18.0
Syntax
json_patch(target, patch)
Parameters
| Parameter | Description |
|---|---|
target |
The original JSON. |
patch |
The changes. |
Return value
The merged JSON text.
Examples
SELECT json_patch('{"theme":"light","lang":"en"}', '{"theme":"dark"}') AS merged;
Output
merged
{"theme":"dark","lang":"en"}SELECT json_patch('{"a":1,"b":2}', '{"b":null,"c":3}') AS result;
Output
result
{"a":1,"c":3}Version history
| Version | Change |
|---|---|
| SQLite 3.18.0 | Added |
In other languages
JSONB_SET()· PostgreSQL
Related
JSON_SET()· Return JSON with values set at paths, creating or overwriting them. json_insert() and json_replace() are stricter.JSON_REMOVE()· Return JSON with the elements at the given paths removed. Paths that don't exist are ignored.- SQL String Functions · tutorial