Repository navigation
v3.0.0
Parsed documents now use a flat layout, as yyjson does: one contiguous block of 16-byte values plus a string arena. Parsing is up to 3.9× faster and uses up to 10× less memory, and the library no longer recurses anywhere. Breaking API change; read-only 2.x code compiles unchanged.
Highlights
parse_jsonreturns a read-onlyJsonDoc. Lookups (doc["k"],doc[0]) returnJsonRefviews instead of deep copies. The compiler keeps the document alive while a view is in use.- New:
items()andentries()for iteration;as_string_slice()for zero-copy strings;to_value()for a mutableJsonValuecopy.
- Faster parsing than 2.0.0: mixed documents 3.9× faster (62.6 → 15.9 ms); integers and floats 1.1–1.3×. Serialization is on par or faster.
- Less memory: parsing adds at most about 8× the input size in the worst case (
[0,0,…]), down from 85×, and about 3× for typical documents. - No recursion anywhere: parsing, serialization, copy, conversion and destruction are all iterative, for parsed documents and built trees alike. A 1M-deep built tree works; 2.0 crashed at about 10k.
- No hash flooding: parsed objects use a sorted key index; built objects hash keys with a random seed per object.
Migrating from 2.x
- Mutating a parsed document:
var v = parse_json(s).to_value(), thenv.set(...)/v.append(...). - Keeping a value after its document is gone: use
to_value(). The compiler rejects views that would outlive their document. - Functions that took a parsed
JsonValuecan takeJsonRef[_]orJsonDocinstead.
See CHANGELOG.md for details and benchmarks.