Module com.darkcollective.relix.json


module com.darkcollective.relix.json
A minimal, dependency-free JSON reader and writer for the relix toolchain.

This module exposes three types: JsonWriter — a small streaming builder that produces compact, correctly-escaped JSON text — JsonStrings, the string-literal escaping primitive the writer is built on, for callers that emit a JSON fragment by hand (a MongoDB pipeline stage, a JSON-Lines log record) and need only that piece, and JsonReader, which reads a document back as plain maps and lists. Together they exist so that the various machine-readable serializers (the IR/plan/optimizer JSON emitters and the CLI's query bundle for the playground) share one correct JSON primitive rather than each hand-rolling string concatenation.

Reading and writing sit together deliberately. Escaping is the half of the JSON grammar most easily gotten subtly wrong, and a parser that unescapes in a different module from the writer that escapes is a contract nothing checks — which is what JsonReaderTest's round-trip cases now assert.

Not every JSON reader belongs here: JsonValues in relix-value builds the relix Value tree that data arriving from a source becomes, and returning that type would cost this module its leaf position.

The module deliberately has no relix dependencies, so it can sit at the bottom of the module graph and be required by every producer without introducing a cycle — the same role relix-events plays for observability.