1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00
A high-performance 100% compatible drop-in replacement of "encoding/json" http://jsoniter.com/migrate-from-go-std.html
Go to file
2018-02-13 16:07:14 +08:00
api_tests fix tests 2018-02-05 23:45:42 +08:00
benchmarks gofmt 2018-02-05 22:45:04 +08:00
extra optimize code 2017-09-06 13:18:05 +08:00
output_tests consolidate map tests 2018-02-13 16:07:14 +08:00
skip_tests fix #200, do not use symbolic link in the code 2017-11-30 10:34:05 +08:00
type_tests consolidate map tests 2018-02-13 16:07:14 +08:00
.codecov.yml
.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
build.sh fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
compatible_test.go Fix standard compatiblility 2017-10-27 01:43:41 +08:00
example_test.go
feature_adapter.go implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
feature_any_array.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_bool.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_float.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_int32.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_int64.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_invalid.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_nil.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_number.go gofmt 2018-02-05 22:45:04 +08:00
feature_any_object.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_string.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_uint32.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any_uint64.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_any.go expose OptionalEncoder&OptionalDecoder; add attachment to Stream&Iterator for customized decoder/encoder 2017-11-08 11:41:45 +08:00
feature_config_with_sync_map.go fix build 2018-02-05 23:05:57 +08:00
feature_config_without_sync_map.go implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
feature_config.go implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
feature_iter_array.go #185 add jsoniter.Valid 2017-10-10 08:57:02 +08:00
feature_iter_float.go add ReadNumber for Iterator. 2017-12-17 16:44:04 +08:00
feature_iter_int.go do not use defer() in read int 2017-12-12 18:52:41 +08:00
feature_iter_object.go fix #191 do not always assume the object field is simple string 2017-10-31 22:38:41 +08:00
feature_iter_skip_sloppy.go change jsoniter-sloppy to jsoniter_sloppy 2017-10-23 15:03:44 +08:00
feature_iter_skip_strict.go change jsoniter-sloppy to jsoniter_sloppy 2017-10-23 15:03:44 +08:00
feature_iter_skip.go #185 add jsoniter.Valid 2017-10-10 08:57:02 +08:00
feature_iter_string.go #185 add jsoniter.Valid 2017-10-10 08:57:02 +08:00
feature_iter.go fix #195 when decode float as int, report it clearly 2017-11-15 23:25:12 +08:00
feature_json_number.go fix #180, add missing methods to jsoniter.Number 2017-10-06 17:56:36 +08:00
feature_pool.go expose OptionalEncoder&OptionalDecoder; add attachment to Stream&Iterator for customized decoder/encoder 2017-11-08 11:41:45 +08:00
feature_reflect_array.go Optimize 0-length array case 2018-01-22 14:03:50 -08:00
feature_reflect_extension.go config: add OnlyTaggedField config, only process tagged fields in struct 2018-01-09 17:29:47 +08:00
feature_reflect_map.go fix #140 uintptr will no lock the address from gc 2018-01-21 20:59:18 +08:00
feature_reflect_native.go fix #227, fix empty json.Number 2018-01-25 14:47:50 +08:00
feature_reflect_object.go implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
feature_reflect_optional.go fix #219 should check real value for empty instead of just the pointer for nested field 2018-01-07 13:57:46 +08:00
feature_reflect_slice.go fix #140 uintptr will no lock the address from gc 2018-01-21 20:59:18 +08:00
feature_reflect_struct_decoder.go implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
feature_reflect.go fix #207 delay unsupported type error reporting 2017-12-15 10:13:11 +08:00
feature_stream_float.go
feature_stream_int.go
feature_stream_string.go #153 fix invalid utf8 using same implementation as the standard library 2017-08-29 23:58:51 +08:00
feature_stream.go expose OptionalEncoder&OptionalDecoder; add attachment to Stream&Iterator for customized decoder/encoder 2017-11-08 11:41:45 +08:00
fuzzy_mode_convert_table.md
Gopkg.lock fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
Gopkg.toml fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
jsoniter_1dot8_only_test.go fix #191 do not always assume the object field is simple string 2017-10-31 22:38:41 +08:00
jsoniter_adapter_test.go
jsoniter_alias_test.go
jsoniter_any_array_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter_any_bool_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter_any_float_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter_any_int_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter_any_map_test.go
jsoniter_any_null_test.go
jsoniter_any_object_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter_any_string_test.go fix #228 2018-01-27 16:25:48 +08:00
jsoniter_array_test.go #139 unmarshal non base64 into []byte 2017-07-19 12:04:22 +08:00
jsoniter_bool_test.go replace should.Equal(nil, err) with should.NoError(err) 2017-09-16 16:30:04 -07:00
jsoniter_customize_test.go fix #207 delay unsupported type error reporting 2017-12-15 10:13:11 +08:00
jsoniter_demo_test.go
jsoniter_encode_interface_test.go
jsoniter_enum_marshaler_test.go replace should.Equal(nil, err) with should.NoError(err) 2017-09-16 16:30:04 -07:00
jsoniter_fixed_array_test.go Fix encoding 0-length arrays 2018-01-16 11:02:03 -08:00
jsoniter_float_test.go add ReadNumber for Iterator. 2017-12-17 16:44:04 +08:00
jsoniter_int_test.go fix #227, fix empty json.Number 2018-01-25 14:47:50 +08:00
jsoniter_interface_test.go fix build 2018-01-04 17:18:16 +08:00
jsoniter_invalid_test.go fix #217 when input is null, non-decodable type should not be considered as error, to be compatible with stdlib 2018-01-04 16:19:26 +08:00
jsoniter_io_test.go #133 validate json when Skip() 2017-07-18 09:45:25 +08:00
jsoniter_iterator_test.go
jsoniter_large_file_test.go #139 unmarshal non base64 into []byte 2017-07-19 12:04:22 +08:00
jsoniter_map_test.go
jsoniter_must_be_valid_test.go
jsoniter_nested_test.go
jsoniter_null_test.go Improve stdlib compatibility 2017-09-16 16:57:51 -07:00
jsoniter_object_test.go gofmt 2018-02-05 22:45:04 +08:00
jsoniter_optional_test.go
jsoniter_raw_message_test.go #178 SkipAndReturnBytes should return copy of memory 2017-09-21 20:18:45 +08:00
jsoniter_reader_test.go #133 fix empty struct skip; fix ] as empty array 2017-07-17 09:09:00 +08:00
jsoniter_reflect_native_test.go
jsoniter_skip_test.go fix #190 handle empty input 2017-10-31 22:47:02 +08:00
jsoniter_sloppy_test.go implement skip number and string strictly 2017-07-18 09:01:43 +08:00
jsoniter_stream_test.go #177 flush buffer should check available again 2017-09-21 21:04:45 +08:00
jsoniter_string_test.go #137 fix unicode surrogate incompatibility 2017-07-18 23:17:52 +08:00
jsoniter_struct_decoder_test.go #152 gofmt 2017-08-25 12:53:23 +08:00
jsoniter_struct_encoder_test.go Always skip unexported fields when encoding 2017-09-18 11:02:15 -07:00
jsoniter_wrap_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
jsoniter.go
LICENSE
README.md Update README.md 2018-01-28 22:27:09 +08:00
test.sh
unmarshal_input_test.go #133 validate json when Skip() 2017-07-18 09:45:25 +08:00

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

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