Highlights
- Format 1.6 default, reading 1.0 through 1.6. Writes Format 1.6 by default (column constants, arithmetic and ISO-8601 sequences, string templates, defaults, nullable and sparse nested flattening, child tables, break rows, path entries) and decodes canonical text from every version (
1.0through1.6). - Zero runtime dependencies. Default features use only the Rust standard library. Enable the optional
serdefeature forserde_json::ValueandSerialize/Deserializehelpers. - Exact key order and binary64 parity.
JsonObjectpreserves ECMAScript own-key order (array indices0..=4294967294first, then insertion order).JsonStringhandles valid UTF-8 with zero overhead and preserves lone UTF-16 surrogates losslessly. - 100% byte-for-byte parity. Passes every shared conformance suite (
1.0through1.6and write-profile) and matches@stackdeck/terset(JavaScript) andterset(Python) byte for byte across real datasets and seeded fuzz tests. - Write Profile v1 and v2. Includes
write_prompt,read_rows, and streamingiter_rowsfor structured LLM output.
Install
Zero-dependency core:
[]
= "0.9"
With serde_json::Value and Serialize/Deserialize support:
[]
= { = "0.9", = ["serde"] }
Quick start
use ;
Pinning an earlier format version
use ;
let input = parse_json?;
let v15 = encode_with?;
Using the optional serde feature
Write profile (v1, v2, and streaming)
Use the write profile when your code defines the columns and a language model writes the rows.
use ;
let cols = ;
// Compact v2 mode (trims trailing tabs, accepts 1/0 booleans, uses --- end line)
let opts = compact;
let prompt = write_prompt?;
// Batch parse
let rows = read_rows?;
assert_eq!;
// Incremental streaming parse from LLM token chunks
let chunks = ;
let streamed: = iter_rows?
.?;
assert_eq!;
Throughput benchmark
Measured on Apple Silicon (cargo run --release --example bench, Format 1.6 encode and strict canonical decode):
| Dataset | JSON bytes | Terset 1.6 bytes | Rust enc (ms) | JS enc (ms) | Py enc (ms) | Rust dec (ms) | JS dec (ms) | Py dec (ms) | serde_json ser/de (ms) | Rust vs JS enc | Rust vs Py enc |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 11-case suite | 118,257 | 53,911 | 26.5 | 53.4 | 112.9 | 33.3 | 38.3 | 143.8 | 0.46 / 4.45 | 2.0x | 4.3x |
| NWS Weather (LWX) | 75,164 | 23,576 | 5.9 | 9.1 | 123.3 | 7.5 | 11.1 | 212.1 | 0.10 / 0.32 | 1.5x | 21.0x |
| USGS Earthquakes | 157,389 | 53,480 | 6.5 | 9.3 | 127.9 | 12.6 | 18.2 | 171.6 | 0.35 / 4.69 | 1.4x | 19.6x |
Note: Terset decode runs full canonical validation (including re-encoding verification) on every call, whereas serde_json performs raw JSON parsing only.
Verification
Run the full conformance, write-profile, cross-language parity, and clippy checks:
License
MIT. See LICENSE.