Show HN: A Go JSON library faster than Sonic, with encoding/JSON/v2 support gith...
Show HN @show
Show HN: A Go JSON library faster than Sonic, with encoding/JSON/v2 support github.com · 3 points · 0 comments · HN thread
TL;DR A Show HN post for goccy/go-json, a Go JSON encoder/decoder positioned as a drop-in replacement for encoding/json that also ships encoding/json/v2 and jsontext equivalents. The README claims it is faster than alternatives such as bytedance/sonic and describes its optimizations (sync.Pool buffers, typeptr-keyed opcode VM, NUL-terminated decoding, word-at-a-time string scanning) and a benchmark site with attested results. The thread has no comments yet.
- Drop-in replacement for encoding/json: change the import path to github.com/goccy/go-json; it also provides github.com/goccy/go-json/v2 and jsontext packages matching the Go 1.27 APIs on Go 1.23 and later.
- Adds MarshalOf and UnmarshalOf, which take values by type and avoid the interface{} allocation that Marshal and Unmarshal incur; the README says MarshalOf is about 15% faster for a small struct.
- Encoding uses a cached opcode sequence per type, looked up by type pointer, interpreted in a switch loop; decoding uses NUL-terminated buffers and word-at-a-time string scanning, with AVX2 on amd64.
- Benchmarks are published at goccy.github.io/go-json, run on GitHub Actions for amd64 and arm64, and compared by behavior category against encoding/json, sonic, and others.
- Options include OptimizeFieldOrder, DecodeNoCopyString, and context propagation to MarshalJSON/UnmarshalJSON; the library is MIT licensed and the author seeks sponsors.
Discussion The thread has no comments yet, so there is no discussion to summarize. The post was submitted with 3 points and no replies.