Skip to main content

Module json

Module json 

Source
Expand description

JSON → clean text + structure-aware chunks (EPIC 12.13).

Valid JSON is rendered as stable pretty text and chunked by its top-level structure (one chunk per array element / object entry) so each chunk is a self-contained record. Invalid JSON degrades gracefully to a single chunk — the seam must never panic or drop content for arbitrary input.

Functions§

chunks
Structure-aware chunks: array ⇒ one chunk per element; object ⇒ one chunk per "key": value entry; scalar/invalid ⇒ a single chunk. Never empty for non-empty input.
to_text
Render input as normalized JSON text (pretty, stable key order via serde). Falls back to the trimmed input when it is not valid JSON.