A high-performance 100% compatible drop-in replacement of "encoding/json"
Clone or download
taowen Merge pull request #304 from Quasilyte/quasilyte/emptyFallthrough
use multi-value case clause instead of fallthrough
Latest commit 2433035 Sep 14, 2018
Permalink
Failed to load latest commit information.
any_tests any_tests: remove commented-out code Sep 13, 2018
api_tests merge Jul 1, 2018
benchmarks gofmt Feb 24, 2018
extension_tests fix #295 decoder more was not compatible with standard library Aug 6, 2018
extra simplify `x = x <op> y` to `x <op>= y` Sep 13, 2018
misc_tests remove redundant dereferencing expressions Sep 13, 2018
skip_tests gofmt Feb 24, 2018
type_tests fix #286 calcHash should use byte not rune to calc hash Aug 6, 2018
value_tests fix #291 omit empty was not handled properly for json raw message Aug 6, 2018
.codecov.yml import github.com/stretchr/testify/require Jul 7, 2017
.gitignore fix #198, use dep for vendoring Nov 30, 2017
.travis.yml travis: add 1.x to go versions Sep 7, 2017
Gopkg.lock add tests for #283 Jul 1, 2018
Gopkg.toml add tests for #283 Jul 1, 2018
LICENSE Initial commit Nov 30, 2016
README.md always benchmark yourself Apr 3, 2018
adapter.go fix #295 decoder more was not compatible with standard library Aug 6, 2018
any.go move reflect2 from plz to modern-go Feb 28, 2018
any_array.go remove feature prefix Feb 19, 2018
any_bool.go remove feature prefix Feb 19, 2018
any_float.go remove feature prefix Feb 19, 2018
any_int32.go remove feature prefix Feb 19, 2018
any_int64.go remove feature prefix Feb 19, 2018
any_invalid.go remove feature prefix Feb 19, 2018
any_nil.go remove feature prefix Feb 19, 2018
any_number.go remove feature prefix Feb 19, 2018
any_object.go remove feature prefix Feb 19, 2018
any_str.go rename Feb 19, 2018
any_uint32.go remove feature prefix Feb 19, 2018
any_uint64.go remove feature prefix Feb 19, 2018
build.sh fix #198, use dep for vendoring Nov 30, 2017
config.go fix #291 omit empty was not handled properly for json raw message Aug 6, 2018
example_test.go gofmt Feb 24, 2018
fuzzy_mode_convert_table.md update conversion table Jul 12, 2017
iter.go remove feature prefix Feb 19, 2018
iter_array.go remove feature prefix Feb 19, 2018
iter_float.go use multi-value case clause instead of fallthrough Sep 13, 2018
iter_int.go fix #241, support 32bit platform Feb 23, 2018
iter_object.go fix #286 calcHash should use byte not rune to calc hash Aug 6, 2018
iter_skip.go remove feature prefix Feb 19, 2018
iter_skip_sloppy.go remove feature prefix Feb 19, 2018
iter_skip_sloppy_test.go remove feature prefix Feb 19, 2018
iter_skip_strict.go remove feature prefix Feb 19, 2018
iter_str.go remove feature prefix Feb 19, 2018
jsoniter.go document public symbols Jul 9, 2017
pool.go Release writer to enable GC Apr 7, 2018
reflect.go fix #293 copy extensions Jul 22, 2018
reflect_array.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_dynamic.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_extension.go fix #293 copy extensions Jul 22, 2018
reflect_json_number.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_json_raw_message.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_map.go fix #293 copy extensions Jul 22, 2018
reflect_marshaler.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_native.go \n should not be ignored in base64 decode May 26, 2018
reflect_optional.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_slice.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_struct_decoder.go Fix case sensitivity for nested fields Jun 12, 2018
reflect_struct_encoder.go move reflect2 from plz to modern-go Feb 28, 2018
stream.go fix #244 use BinaryAsStringExtension to make []byte pretty, while th… Feb 27, 2018
stream_float.go remove feature prefix Feb 19, 2018
stream_int.go gofmt Feb 24, 2018
stream_str.go remove feature prefix Feb 19, 2018
stream_test.go remove feature prefix Feb 19, 2018
test.sh fix coverage Feb 14, 2018

README.md

Sourcegraph GoDoc Build Status codecov rcard License Gitter chat

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

You can also use thrift like JSON using thrift-iterator

Go开发者们请加入我们,滴滴出行平台技术部 taowen@didichuxing.com

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 "github.com/json-iterator/go"

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

Replace

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

with

import "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 taowen@gmail.com, or Gitter chat