go README

The project's README from github.com/json-iterator/go. As one markdown file: README.md.

Sourcegraph GoDoc Build Status codecov rcard License Gitter chat

A high-performance 100% compatible drop-in replacement of "encoding/json"

Benchmark

benchmark

Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go

Raw Result (easyjson requires static code generation)

ns/op allocation bytes allocation times
std decode 35510 ns/op 1960 B/op 99 allocs/op
easyjson decode 8499 ns/op 160 B/op 4 allocs/op
jsoniter decode 5623 ns/op 160 B/op 3 allocs/op
std encode 2213 ns/op 712 B/op 5 allocs/op
easyjson encode 883 ns/op 576 B/op 3 allocs/op
jsoniter encode 837 ns/op 384 B/op 4 allocs/op

Always benchmark with your own workload. The result depends heavily on the data input.

Usage

100% compatibility with standard lib

Replace

import "encoding/json"
json.Marshal(&data)

with

import jsoniter "github.com/json-iterator/go"

var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Marshal(&data)

Replace

import "encoding/json"
json.Unmarshal(input, &data)

with

import jsoniter "github.com/json-iterator/go"

var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Unmarshal(input, &data)

More documentation

How to get

go get github.com/json-iterator/go

Contribution Welcomed !

Contributors

Report issue or pull request, or email [email protected], or Gitter chat

go (json-iterator/go)

Searching Database…

13.9K ·GitHub
archived
What is this?A high-performance JSON library for Go, positioned as a 100% compatible drop-in replacement for the standard encoding/json package: you swap the import and keep your code.
Is this a library I import, or a tool I run?A Go library. You import it in place of encoding/json and call it from your own code — there is no binary, server, or code-generation step involved.
How do I switch my project over to it?Run go get github.com/json-iterator/go and replace your encoding/json import with jsoniter. The ConfigCompatibleWithStandardLibrary configuration keeps behavior identical to the standard library.
Does it need anything besides Go itself?No — just the Go toolchain. Unlike easyjson, it needs no static code generation before you can use it.
Is the project still actively maintained?No — the GitHub repository has been archived and is read-only, so it gets no further updates. The library still works, but do not expect bug fixes or new features.
Will it behave the same on Linux, macOS, and Windows?There are no OS-specific requirements: it is a pure Go library, so it builds and runs anywhere the Go toolchain does.
How much faster is it than the standard encoding/json?By the README benchmarks: decoding 5623 ns/op versus 35510 for the std lib (about 6x) with 3 allocations instead of 99; encoding 837 ns/op versus 2213 (about 2.6x) with 384 instead of 712 bytes allocated.
Will I see the same speedup on my own data?Not necessarily — the README explicitly warns to always benchmark with your own workload, because results depend heavily on the data input.
How does it compare to easyjson?On the same benchmark table it is slightly faster both ways (5623 vs 8499 ns/op decode, 837 vs 883 encode), and unlike easyjson it requires no static code generation.
What are similar projects?gjson, fastjson, SwiftyJSON, simdjson, nom, REDox, liteparse, goquery
Size
1.2 MB
Stars
13.9K
Age
9y
Commits · 90 Days