go
A high-performance 100% compatible drop-in replacement of "encoding/json"
jsoniter is a fast, drop-in replacement for Go's built-in JSON library, it encodes and decodes JSON data significantly faster and with less memory, requiring only a one-line import change in your existing Go code.
This repository, often called jsoniter, is a code library for the Go programming language that handles JSON. JSON is a common text format used to pass structured information between programs, for example what a web server sends back to an app. Go already comes with a built-in tool for this job, a standard package named encoding/json. The README describes jsoniter as a high-performance, 100 percent compatible drop-in replacement for that built-in tool. In plain terms, it does exactly the same work but faster, and you can switch to it without changing how your code is written.
Most of the README is given over to a benchmark, which is a speed test comparing libraries. A table measures how long each option takes to decode and encode the same data, along with how much memory it uses. The figures show jsoniter decoding noticeably faster than Go's standard library while using far less memory, and edging out another library called easyjson. The author adds a sensible caveat: you should always run the test with your own data, because results depend heavily on what the data looks like.
The usage section shows how little effort switching takes. Where you would normally import the standard encoding/json package and call its Marshal function (which turns Go data into JSON text) or Unmarshal function (which reads JSON text back into Go data), you instead import jsoniter and point a variable at its compatible configuration. After that one-line change, the same Marshal and Unmarshal calls work as before. A link points to fuller documentation for migrating from the standard library.
Installing it is a single command, go get followed by the package address, which is the normal way to add a Go library. The README closes by welcoming contributions, listing several named contributors, and giving ways to get involved or ask for help: opening an issue or pull request, emailing the maintainer, or joining a Gitter chat room. The project is released under the MIT license. The README is short and focused purely on speed and compatibility.
Where it fits
- Speed up JSON serialization and deserialization in an existing Go service by swapping in jsoniter with a single import change.
- Reduce memory allocations in a high-throughput Go API that processes large JSON payloads.
- Benchmark JSON encoding performance in your own Go project to verify the speed gains match your specific data shape.