Repository navigation
v2.0.0
Correctness, security and performance overhaul. Parsing is now strict RFC 8259, and every number is converted exactly. Contains breaking changes; see below.
Highlights
- Strict RFC 8259 parsing. Passes every applicable accept/reject case of JSONTestSuite.
- Exact numbers.
- Int64 integers are stored exactly; they used to overflow silently past 18 digits.
- Floats are correctly rounded (Eisel-Lemire plus an exact fallback). The parser no longer uses Mojo's stdlib
atof, which isn't correctly rounded.
- Exact float output. Floats print with Schubfach in CPython
reprstyle, byte-identical to Python'srepr, and parse back to the same value bit for bit. - Full Unicode.
\uXXXXescapes, including surrogate pairs, decode to UTF-8. - Hardened for untrusted input.
- A nesting limit (
max_depth=512) replaces a stack-overflow crash. - Large objects use a hash index: a 100k-key object went from 18 s to 3 ms.
- Memory use is bounded better.
- Error messages are safe to log.
- A nesting limit (
- New API:
append(),set(),json_int(),is_int(). - Serialization is 2–5× faster.
Breaking changes
- Input that RFC 8259 forbids now raises:
01,1.,\x, raw control characters, lone surrogates,1e400. - Integral floats keep their
.0(100.0, not100), and exponents look like1e+16/1e-05. Integers are unchanged. len()of a string value counts codepoints, not bytes.as_int()/get_int()raise for floats outside Int64 range.
Upgrading
json.mojo is still a single self-contained file: replace your copy, or update the submodule, and rebuild. Requires Mojo ≥ 1.0.0.
See CHANGELOG.md for the full list, benchmarks and known limitations. 71 tests, conformance and differential fuzzing run in CI on Linux and macOS.