1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-19 20:31:49 +02:00
A high-performance 100% compatible drop-in replacement of "encoding/json" http://jsoniter.com/migrate-from-go-std.html
Go to file
Tao Wen 71ac16282d
Merge pull request #635 from molon/fix-tests
encoding/json: Compatibility optimization
2022-09-16 07:37:16 +08:00
any_tests fix #313 support json marshaller type as map key 2018-10-24 23:28:41 +08:00
api_tests Revert "Merge pull request #418 from bbrks/configurable_maxDepth" 2019-12-19 19:06:29 -05:00
benchmarks benchmarks: add benchmark for Stream 2020-01-17 16:50:46 -05:00
extension_tests fix nil attachment on stream in custom encoder on sorted map 2019-11-28 17:39:42 +03:00
extra fix: invalid unicode while binary to string 2021-07-19 13:58:16 +08:00
misc_tests jsoniter: Fix errors during reading integers from chunked io.Reader (#477) 2020-08-06 09:14:08 +08:00
skip_tests fix #37: add SkipAndAppendBytes iterator method 2019-06-10 12:40:05 +03:00
type_tests disable map_key_test temporarily 2020-05-08 15:08:25 +08:00
value_tests encoding/json: use standard ES6 formatting for numbers during marshal 2022-09-15 22:10:44 +08:00
.codecov.yml import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
.gitignore fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
.travis.yml travis: add 1.x to go versions 2017-09-07 17:12:42 +02:00
adapter.go Fix typo in UnmarshalFromString documentation 2019-05-21 12:48:31 +01:00
any_array.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_bool.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_float.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_int32.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_int64.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_invalid.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_nil.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_number.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_object.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_str.go fix any str ToInt64 ToUint64 panic 2020-03-26 18:17:29 +08:00
any_uint32.go remove feature prefix 2018-02-19 23:04:25 +08:00
any_uint64.go remove feature prefix 2018-02-19 23:04:25 +08:00
any.go fix #311 handle nil any 2018-10-24 21:05:37 +08:00
build.sh fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
config.go fix issue #389 #411 2020-01-14 14:14:02 +08:00
example_test.go rename ExampleMyKey 2019-01-10 17:51:25 +01:00
fuzzy_mode_convert_table.md update conversion table 2017-07-13 00:13:04 +08:00
go.mod bumped stretchr to v1.8.0 to get rid of yaml v2 vuln 2022-08-04 17:25:33 +01:00
go.sum bumped stretchr to v1.8.0 to get rid of yaml v2 vuln 2022-08-04 17:25:33 +01:00
Gopkg.lock add tests for #283 2018-07-01 13:05:25 +08:00
Gopkg.toml add tests for #283 2018-07-01 13:05:25 +08:00
iter_array.go Limit nesting depth 2019-10-08 11:17:01 -04:00
iter_float.go fix issue 510 2020-11-17 17:37:55 +08:00
iter_int.go fix issue 510 2020-11-17 17:37:55 +08:00
iter_object.go fix the error message typo of ReadObjectCB & ReadMapCb function 2020-01-03 15:31:12 +08:00
iter_skip_sloppy_test.go remove feature prefix 2018-02-19 23:04:25 +08:00
iter_skip_sloppy.go Limit nesting depth 2019-10-08 11:17:01 -04:00
iter_skip_strict.go fix #317, try parse as BigFloat if overflow 2018-11-12 14:45:56 +08:00
iter_skip.go fix #37: add SkipAndAppendBytes iterator method 2019-06-10 12:40:05 +03:00
iter_str.go remove feature prefix 2018-02-19 23:04:25 +08:00
iter.go Revert "Merge pull request #418 from bbrks/configurable_maxDepth" 2019-12-19 19:06:29 -05:00
jsoniter.go document public symbols 2017-07-09 16:09:23 +08:00
LICENSE Initial commit 2016-11-30 08:30:24 +08:00
pool.go Release writer to enable GC 2018-04-07 21:40:08 +10:00
README.md fix go 1.18 compatibility 2021-09-11 10:17:26 +08:00
reflect_array.go move reflect2 from plz to modern-go 2018-02-28 17:09:30 +08:00
reflect_dynamic.go move reflect2 from plz to modern-go 2018-02-28 17:09:30 +08:00
reflect_extension.go fix issue #449 2020-03-26 14:46:47 +08:00
reflect_json_number.go move reflect2 from plz to modern-go 2018-02-28 17:09:30 +08:00
reflect_json_raw_message.go fix issue #469 2020-07-21 17:07:23 +08:00
reflect_map.go encoding/json: allow non-string type keys for (un-)marshal 2022-09-15 22:07:27 +08:00
reflect_marshaler.go use json.Marshaler then trim the last '\n' in reflect_marshaler 2019-08-14 10:10:02 +08:00
reflect_native.go Don't marshal empty byte or uint8 slice as null 2019-06-03 16:19:17 +05:30
reflect_optional.go temporarily comment out some test case to fix the CI fail since go1.14 released 2020-03-30 16:42:45 +08:00
reflect_slice.go move reflect2 from plz to modern-go 2018-02-28 17:09:30 +08:00
reflect_struct_decoder.go fixed null in number json tag string (#480) 2020-08-03 10:12:41 +08:00
reflect_struct_encoder.go fix nil attachment on stream in custom encoder on sorted map 2019-11-28 17:39:42 +03:00
reflect.go fix issue 508 2020-11-13 15:58:42 +08:00
stream_float.go encoding/json: use standard ES6 formatting for numbers during marshal 2022-09-15 22:10:44 +08:00
stream_int.go gofmt 2018-02-24 22:04:41 +08:00
stream_str.go remove feature prefix 2018-02-19 23:04:25 +08:00
stream_test.go (*Stream).WriteMore: remove implicit Flush 2020-01-17 22:14:50 -05:00
stream.go (*Stream).WriteMore: remove implicit Flush 2020-01-17 22:14:50 -05:00
test.sh fix coverage 2018-02-14 14:06:32 +08:00

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