Skip to content
A high-performance 100% compatible drop-in replacement of "encoding/json"
Go Shell
Branch: master
Clone or download
taowen Merge pull request #416 from jarredhawkins/issue-415
Ignore unnamed literals in structs
Latest commit dc11f49 Oct 30, 2019
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 use json.Marshaler then trim the last '\n' in reflect_marshaler Aug 14, 2019
benchmarks gofmt Feb 24, 2018
extension_tests fix #313 support json marshaller type as map key Oct 24, 2018
extra simplify `x = x <op> y` to `x <op>= y` Sep 13, 2018
misc_tests Limit nesting depth Oct 8, 2019
skip_tests fix #37: add SkipAndAppendBytes iterator method Jun 10, 2019
type_tests Unnamed struct literals Oct 29, 2019
value_tests fix #317, try parse as BigFloat if overflow Nov 12, 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 update README Mar 6, 2019
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 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 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 Limit nesting depth Oct 8, 2019
iter_array.go Limit nesting depth Oct 8, 2019
iter_float.go clean readPositiveFloat64 Jan 10, 2019
iter_int.go fix #241, support 32bit platform Feb 23, 2018
iter_object.go Limit nesting depth Oct 8, 2019
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 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 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 Unnamed struct literals Oct 29, 2019
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 Fixes #405 - Encode nil map into null Sep 19, 2019
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 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 Limit nesting depth Oct 8, 2019
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 the… Feb 27, 2018
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 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

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

You can’t perform that action at this time.