SQLite 3 reference · JSON Functions

SQLite JSON_SET() Function

Return JSON with values set at paths, creating or overwriting them. json_insert() and json_replace() are stricter.

SQLite 3 Since 3.9.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

json_set(json, path, value, ...)

Parameters

ParameterDescription
json JSON text (or JSONB).
path A path such as '$.name', '$.items[0]' or '$.items[#-1]' (last element).
value The new value.

Return value

The modified JSON text.

Examples

Overwrite and addTry it yourself
SELECT json_set('{"name":"Ada"}', '$.name', 'Grace', '$.age', 36) AS updated;

Output

updated
{"name":"Grace","age":36}
Append to an arrayTry it yourself
SELECT json_set('{"tags":["a"]}', '$.tags[#]', 'b') AS appended;

Output

appended
{"tags":["a","b"]}

Version history

VersionChange
SQLite 3.9.0Added
SQLite 3.38.0Built in by default; earlier versions needed the JSON1 extension.

In other languages

Was this page helpful?