data.drivers._pelt._codecs_json

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

E2 codec family:json / jsonb.

PostgreSQL's two document types decode to a parsed Python object (whatever loads() yields — dict / list / str / int / float/ …

E2 codec family:json / jsonb.

PostgreSQL's two document types decode to a parsed Python object (whatever loads() yields — dict / list / str / int / float / bool/ None) and encode from one via dumps(). The two differ only in their binary wire framing:

  • json(OID 114) stores the document verbatim, so its binary format is identical to its text format: UTF-8 JSON bytes, no envelope.
  • jsonb (OID 3802) prefixes the UTF-8 JSON with a single version byte. Version 1 is the only one PostgreSQL has ever emitted (jsonb_send writes 0x01then the decompressed text;jsonb_recvreads the version then the text). A byte other than 0x01means the stream desynced or the server speaks a future format pelt does not know — that is aProtocolError, never a silent best-effort decode.

These are leaf (non-parametric) codecs — the registry registers them directly from LEAF_CODECS. Composite/array families that contain json land separately in E2. Live-PG parity is deferred to E4/E6 integration; the binary vectors here are pinned to the documentedjsonbwire layout.

data.drivers._pelt._codecs_json

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

_dumps
function
def _dumps(value: Any) -> bytes

Serialize a Python object to compact UTF-8 JSON bytes.

Compact == no whitespace between tokens (separators=(",", ":")). PostgreSQL parses json/jsonb regardless of internal whitespace, so dropping the spaces is wire-safe and shrinks the payload.

Parameters

Name Type Default Description
value Any
_loads
function
def _loads(data: bytes) -> Any

Parse UTF-8 JSON bytes to a Python object, surfacing faults asProtocolError.

Parameters

Name Type Default Description
data bytes
_json_codec
function
def _json_codec() -> Codec

json(OID 114): binary == text == UTF-8 JSON, no envelope.

No parameters.

_jsonb_codec
function
def _jsonb_codec() -> Codec

jsonb (OID 3802): binary is 0x01+ UTF-8 JSON; text is bare UTF-8 JSON.

No parameters.

View source · /home/runner/work/chirp/chirp/site/../src/chirp/data/drivers/_pelt/_codecs_json.py:1