SQLite 3 reference · JSON Functions
SQLite JSONB() Function
Convert JSON text to SQLite's binary JSONB format, which is faster to process. Every json_ function has a jsonb_ version.
SQLite 3 Since 3.45.0
Syntax
jsonb(X)
Parameters
| Parameter | Description |
|---|---|
X |
JSON text or JSONB. |
Return value
A BLOB in JSONB format.
Examples
SELECT typeof(jsonb('{"a":1}')) AS stored_as, json(jsonb('{"a": 1}')) AS back_to_text;
Output
stored_as | back_to_text
blob | {"a":1}SELECT jsonb_extract(jsonb('{"a":[1,2]}'), '$.a[1]') AS value;
Output
value 2
JSONB is SQLite's own format, not PostgreSQL's jsonb: store it in BLOB columns and read it back with
json() when you need text.
Version history
| Version | Change |
|---|---|
| SQLite 3.45.0 | Added |
Related
JSON()· Check and minify JSON text: return it without extra whitespace, or raise an error if it isn't valid JSON.JSON_EXTRACT()· Read one or more values from JSON by path. JSON objects and arrays come back as text; numbers and strings as SQL values.- SQL String Functions · tutorial