Choosing a mode
Four ways to write the same data. One reader decodes them all.
| You are⦠| Use | Why |
|---|---|---|
| Asking a model about data | ask() for counts and totals, the prompt builder for the rest | Exact answers; prompts tuned on live runs |
| Moving data between services | Compact, with gzip or brotli | Smallest format once compressed |
| Writing logs, fixtures or docs | Readable | Full values, no steps or ^ marks |
| Exchanging data with a declared format | Typed | Self-identifying first line |
| Writing or reading huge tables | Streaming | One row at a time, flat memory |
Compact
The default. Uses every header form: steps, prefixes, dictionaries, constants and ^ repeats.
jdogo.dumps(data) # or jdogo.doc_encode(data)
stringify(data) // or docEncode(data)
DocCodec.encode(data)
jdogo compact data.json
Readable
Full keys and values, nothing hoisted or repeated. About 16% more tokens than compact and still about 43% fewer than JSON across the 200 test cases.
jdogo.dumps(data, mode="readable") # or jdogo.encode_readable(data)
stringify(data, "readable") // or encodeReadable(data)
DocCodec.encodeLegibleKeys(data)
jdogo compact --readable data.json
Typed
A first line !JDOGO/2 @doc, then a compact document. Use it when a receiver must know what it's reading before it parses.
jdogo.dumps(data, mode="typed")
stringify(data, "typed")
// FormatMode.TYPED through JDogoMapper
jdogo compact -m typed data.json
Compress for transfer
JDogo already removes repeated keys, but gzip still shortens values that repeat across rows. Gzipped, the 200 test cases take 332 KB in JDogo, against 399 KB in TOON, 417 KB in binary Avro and 480 KB in JSON. Set Content-Encoding: gzip or br as you would for JSON.
Uncompressed, binary Avro with a schema agreed in advance is smaller on some payloads, such as agent traces and delimiter-heavy text.
Reading: one call for everything
jdogo.loads, parse and DocCodec.decode read compact, readable and typed documents and plain JSON. Python and TypeScript also fall back to the 1.x format, so old data keeps working.
Streaming
For tables too big to hold in memory, see Streaming. Streamed output is larger than dumps output, because the writer chooses cells before it has seen later rows.