Skip to content
A high-performance 100% compatible drop-in replacement of "encoding/json"
Go Shell
Branch: master
Clone or download

Latest commit

Latest commit a1ca083 Jun 8, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
any_tests fix #313 support json marshaller type as map key Oct 24, 2018
api_tests Revert "Merge pull request #418 from bbrks/configurable_maxDepth" Dec 20, 2019
benchmarks benchmarks: add benchmark for Stream Jan 17, 2020
extension_tests fix nil attachment on stream in custom encoder on sorted map Nov 28, 2019
extra fix issue #449 Mar 26, 2020
misc_tests add more testcase Jan 16, 2020
skip_tests fix #37: add SkipAndAppendBytes iterator method Jun 10, 2019
type_tests disable map_key_test temporarily May 8, 2020
value_tests Map keys of custom types should serialize using MarshalText when avai… May 8, 2020
.codecov.yml import github.com/stretchr/testify/require Jul 7, 2017
.gitignore fix #198, use dep for vendoring Nov 30, 2017
.travis.yml
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 update readme (#464) Jun 8, 2020
adapter.go Fix typo in UnmarshalFromString documentation May 21, 2019
any.go fix #311 handle nil any Oct 24, 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 fix any str ToInt64 ToUint64 panic Mar 26, 2020
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 issue #389 #411 Jan 14, 2020
example_test.go rename ExampleMyKey Jan 10, 2019
fuzzy_mode_convert_table.md update conversion table Jul 12, 2017
go.mod Add go module definition Apr 25, 2019
go.sum Add go module definition Apr 25, 2019
iter.go Revert "Merge pull request #418 from bbrks/configurable_maxDepth" Dec 20, 2019
iter_array.go Limit nesting depth Oct 8, 2019
iter_float.go
iter_int.go fix #241, support 32bit platform Feb 23, 2018
iter_object.go fix the error message typo of ReadObjectCB & ReadMapCb function Jan 3, 2020
iter_skip.go fix #37: add SkipAndAppendBytes iterator method Jun 10, 2019
iter_skip_sloppy.go Limit nesting depth Oct 8, 2019
iter_skip_sloppy_test.go remove feature prefix Feb 19, 2018
iter_skip_strict.go fix #317, try parse as BigFloat if overflow Nov 12, 2018
iter_str.go
jsoniter.go document public symbols Jul 9, 2017
pool.go Release writer to enable GC Apr 7, 2018
reflect.go Limit nesting depth Oct 8, 2019
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 issue #449 Mar 26, 2020
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 remove quotation check for key when decoding map May 31, 2020
reflect_marshaler.go use json.Marshaler then trim the last '\n' in reflect_marshaler Aug 14, 2019
reflect_native.go Don't marshal empty byte or uint8 slice as null Jun 3, 2019
reflect_optional.go temporarily comment out some test case to fix the CI fail since go1.1… Mar 30, 2020
reflect_slice.go move reflect2 from plz to modern-go Feb 28, 2018
reflect_struct_decoder.go fix issue #421 Jan 15, 2020
reflect_struct_encoder.go fix nil attachment on stream in custom encoder on sorted map Nov 28, 2019
stream.go (*Stream).WriteMore: remove implicit Flush Jan 18, 2020
stream_float.go fix #365, return error for +inf -inf and NaN May 23, 2019
stream_int.go gofmt Feb 24, 2018
stream_str.go remove feature prefix Feb 19, 2018
stream_test.go (*Stream).WriteMore: remove implicit Flush Jan 18, 2020
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

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

You can’t perform that action at this time.