SQLite JSON_INSERT() Function
Example
Add an age, but keep the existing name:
SELECT JSON_INSERT('{"name": "Emil"}',
'$.name', 'Nora', '$.age', 30);
Try it Yourself »
Definition and Usage
The JSON_INSERT() function adds values to a JSON text, and returns the new JSON. If a path already exists, the old value is kept.
Note: Read more about JSON in the SQLite JSON chapter.
Tip: Also look at JSON_REPLACE(), JSON_SET().
Syntax
JSON_INSERT(json, path, value, ...)
Parameter Values
| Parameter | Description |
|---|---|
| json | Required. The JSON text |
| path | Required. A JSON path, like '$.name' for a value in an object, '$[0]' for the first item in an array, or '$.a.b' for a value inside another object |
| value | Required. The value to add |
Technical Details
| Return type: | Text |
|---|