If you're going for pure performance in a production environment you might take a look at Daniel Lemire's work: https://github.com/simdjson/simdjson. Or the MinIO port of it to Go: https://github.com/minio/simdjson-go.
If you're going for pure performance in a production environment you might take a look at Daniel Lemire's work: https://github.com/simdjson/simdjson. Or the MinIO port of it to Go: https://github.com/minio/simdjson-go.
Perhaps some macro-ridden Rust monstrosity that spits out specialised parsers at compile time, dynamically…
[1] https://github.com/omissis/go-jsonschema [2] https://github.com/pquerna/ffjson
Schemas can't fix that.
Otherwise there is no need to keep a buffer of anything after it has been parsed.
Let's assume I send you a JSON object that is one very long string and nothing else. It's e.g. 1 GB in size. To know you need to allocate a 1GB buffer, you need to first scan it, and then copy it; or keep reallocating the same buffer until it fits.
It's an absurd case, but shorter strings face similar overhead.
I'll definitely agree that most things won't fully take advantage of that even if you provide that information, but it is definitely possible to do so.
That said, JSON is designed for human readability above performance, so it's a design concession that makes sense. What doesn't make sense is using JSON anywhere performance matters.
If you’re building something net-new and know you’ll have these problems out the gate, something other than JSON might be feasible, but the moment some other system not in the closed loop needs to work with the data, you’re back to JSON and any associated perf issues.
The repository has benchmarks
[1] https://github.com/bytedance/sonic/blob/main/docs/INTRODUCTI...