Documentation Source Text

Check-in [3f84dd678e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further clarification to what JSONB is and why it is useful.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | jsonb
Files: files | file ages | folders
SHA3-256: 3f84dd678e3891efc7b54a501381cef0d08071a5c0194a650bbbbf463d918059
User & Date: drh 2023-10-12 11:40:37
Context
2023-10-12
11:46
Further clarification of JSONB and typo fixes. (check-in: e95f7ea68f user: drh tags: jsonb)
11:40
Further clarification to what JSONB is and why it is useful. (check-in: 3f84dd678e user: drh tags: jsonb)
2023-10-11
16:07
Further enhancements to the JSONB documentation to help clarify its design and purpose. (check-in: 0ae7f4829c user: drh tags: jsonb)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pages/json1.in.

289
290
291
292
293
294
295
















296
297
298
299
300
301
302
303
304
305
306
307
308
SQLite is that it is smaller and faster than text JSON - potentially several
times faster. There is space in the
on-disk JSONB format to add enhancements and future versions of SQLite might
include options to provide O(1) lookup of elements in JSONB, but no such
capability is currently available.

<p>
















The binary format used for JSONB is intended to be private to
SQLite and is for use by the built-in SQLite functions only.  The
JSONB format is not intended as an interchange format.  Nevertheless,
JSONB is stored in database files which are intended to
be readable and writable for many decades.  To that end, the JSONB
format is well-defined and stable. The separate
[SQLite JSONB format] document provides details of the JSONB format
for the curious reader.

<tcl>hd_fragment jsonpath {JSON paths} {JSON function path arguments}</tcl>
<h2>PATH arguments</h2>

<p>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|



|
|







289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
SQLite is that it is smaller and faster than text JSON - potentially several
times faster. There is space in the
on-disk JSONB format to add enhancements and future versions of SQLite might
include options to provide O(1) lookup of elements in JSONB, but no such
capability is currently available.

<p>
The core idea behind SQLite's JSONB is that each element begins with a header
that includes the size and type of that element.  This makes reading
faster.  For example, when reading
a string literal, it is no longer necessary to search forward looking
for the closing double-quote, reading byte by byte and taking care
to avoid escaped double-quotes.  The size of
the literal is right there in the header, and so the process can jump
ahead to the next element without having to scrutinize each
intervening byte.  Since the size and type of each element is
identified in the header, punctuation characters such as string, object,
and array delimiters and comma and colon separators can all be omitted.
The payload for JSONB is the same as the corresponding text JSON.
The only difference is that JSONB omits punctuation and replaces it with
a header on each element.

<p>
The SQLite JSONB format is intended to be private to
SQLite and is for use by the built-in SQLite functions only.  The
JSONB format is not intended as an interchange format.  Nevertheless,
JSONB is stored in database files which are intended to
be readable and writable for many decades into the fugure.
To that end, the JSONB format is well-defined and stable. The separate
[SQLite JSONB format] document provides details of the JSONB format
for the curious reader.

<tcl>hd_fragment jsonpath {JSON paths} {JSON function path arguments}</tcl>
<h2>PATH arguments</h2>

<p>

Changes to pages/jsonb.in.

23
24
25
26
27
28
29













30
31
32
33
34
35
36

<p>
The "JSONB" name is inspired by [https://postgresql.org|PostgreSQL], but the
on-disk format for SQLite's JSONB is not the same as PostgreSQL's.
The two formats have the same name, but they have wildly different internal
representations and are not in any way binary compatible.














<h1>The Purpose Of This Document</h1>

<p>
JSONB is not intended as an external format to be used by
applications.  JSONB is designed for internal use by SQLite only.
Programmers do not need to understand the JSONB format in order to
use it effectively.







>
>
>
>
>
>
>
>
>
>
>
>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

<p>
The "JSONB" name is inspired by [https://postgresql.org|PostgreSQL], but the
on-disk format for SQLite's JSONB is not the same as PostgreSQL's.
The two formats have the same name, but they have wildly different internal
representations and are not in any way binary compatible.

<p>
The central idea behind this JSONB specification is that each element
begins with a header that includes the size and type of that element.
The header takes the place of punctuation such as double-quotes,
curly-brackes, square-brackets, commas, and colons.  Since the size
and type of each element is contained in its header, the element can
be read faster since it is no longer necessary to carefully scan forward
looking for the closing delimiter.  The payload of JSONB is the same
as for corresponding text JSON.  The same payload bytes occur in the
same order.  The only real difference between JSONB and ordinary text
JSON is that JSONB includes a binary header on
each element and omits delimiter and separator punctuation.

<h1>The Purpose Of This Document</h1>

<p>
JSONB is not intended as an external format to be used by
applications.  JSONB is designed for internal use by SQLite only.
Programmers do not need to understand the JSONB format in order to
use it effectively.