SQLite 3 reference · JSON Functions
SQLite JSON_REMOVE() Function
Return JSON with the elements at the given paths removed. Paths that don't exist are ignored.
SQLite 3 Since 3.9.0
Syntax
json_remove(json, path, ...)
Parameters
| Parameter | Description |
|---|---|
json |
JSON text (or JSONB). |
path |
A path such as '$.name', '$.items[0]' or '$.items[#-1]' (last element). |
Return value
The modified JSON text.
Examples
SELECT json_remove('{"name":"Ada","password":"x","age":36}', '$.password') AS safe;
Output
safe
{"name":"Ada","age":36}SELECT json_remove('[10,20,30]', '$[0]') AS without_first, json_remove('[10,20,30]', '$[#-1]') AS without_last;
Output
without_first | without_last [20,30] | [10,20]
Version history
| Version | Change |
|---|---|
| SQLite 3.9.0 | Added |
| SQLite 3.38.0 | Built in by default; earlier versions needed the JSON1 extension. |
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_PATCH()· Merge one JSON object into another using RFC 7396 MergePatch: keys are added or replaced, null removes a key.- SQL String Functions · tutorial