• TCB13@lemmy.world
    link
    fedilink
    English
    arrow-up
    14
    ·
    10 months ago

    Finally.

    What Is JSONB? Beginning with version 3.45.0 (pending), SQLite supports an alternative binary encoding of JSON which we call “JSONB”. JSONB is a binary format that stored as a BLOB.

    The advantage of JSONB over ordinary text RFC 8259 JSON is that JSONB is both slightly smaller (by between 5% and 10% in most cases) and can be processed in less than half the number of CPU cycles. The built-in JSON SQL functions of SQLite can accept either ordinary text JSON or the binary JSONB encoding for any of their JSON inputs.

    The “JSONB” name is inspired by 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.

    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.

    https://sqlite.org/draft/jsonb.html