1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
A high-performance 100% compatible drop-in replacement of "encoding/json" http://jsoniter.com/migrate-from-go-std.html
Go to file
2017-09-14 23:54:40 +08:00
extra optimize code 2017-09-06 13:18:05 +08:00
output_tests Add tests for int64 2017-08-10 20:58:49 -07:00
skip_tests #136 strconv.ParseFloat can not validate 1. , added extra validation for this special case 2017-07-18 22:19:52 +08:00
.codecov.yml import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
.gitignore test and cover multiple packages 2017-07-02 12:58:14 +08:00
.travis.yml travis: add 1.x to go versions 2017-09-07 17:12:42 +02:00
example_test.go fix go vet 2017-07-09 11:24:26 +08:00
feature_adapter.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +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 rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +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 check null/true/false 2017-07-10 15:23:35 +08:00
feature_config.go #166 support ValidateJsonRawMessage in ConfigCompatibleWithStandardLibrary 2017-09-14 23:54:40 +08:00
feature_iter_array.go #133 fix empty struct skip; fix ] as empty array 2017-07-17 09:09:00 +08:00
feature_iter_float.go #138 fix - without following digits; fix 1.e1 2017-07-18 23:48:40 +08:00
feature_iter_int.go document public symbols 2017-07-09 16:09:23 +08:00
feature_iter_object.go #133 validate json when Skip() 2017-07-18 09:45:25 +08:00
feature_iter_skip_sloppy.go implement skip number and string strictly 2017-07-18 09:01:43 +08:00
feature_iter_skip_strict.go #157 number can be null 2017-09-05 13:00:03 +08:00
feature_iter_skip.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
feature_iter_string.go #157 number can be null 2017-09-05 13:00:03 +08:00
feature_iter.go #145 interface {} customizatoin is recursive 2017-08-22 10:39:01 +08:00
feature_json_number.go #152 gofmt 2017-08-25 12:53:23 +08:00
feature_pool.go document public symbols 2017-07-09 16:09:23 +08:00
feature_reflect_array.go #133 fix empty struct skip; fix ] as empty array 2017-07-17 09:09:00 +08:00
feature_reflect_extension.go #146 support config TagKey 2017-08-22 00:12:09 +08:00
feature_reflect_map.go #126 fix space in case map key is sorted 2017-07-11 01:07:18 +08:00
feature_reflect_native.go #166 support ValidateJsonRawMessage in ConfigCompatibleWithStandardLibrary 2017-09-14 23:54:40 +08:00
feature_reflect_object.go #152 gofmt 2017-08-25 12:53:23 +08:00
feature_reflect_slice.go #140 blind fix 2017-08-02 09:20:43 +08:00
feature_reflect_struct_decoder.go #152 gofmt 2017-08-25 12:53:23 +08:00
feature_reflect.go #156 invoke Marshaler defined on pointer types 2017-09-01 15:44:12 +08:00
feature_stream_float.go fix build; add document for exported symbols 2017-07-09 14:48:34 +08:00
feature_stream_int.go fix build; add document for exported symbols 2017-07-09 14:48:34 +08:00
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 ensure buffer flushed to io.Writer 2017-07-16 10:47:24 +08:00
fuzzy_mode_convert_table.md update conversion table 2017-07-13 00:13:04 +08:00
jsoniter_1dot8_only_test.go document public symbols 2017-07-09 16:09:23 +08:00
jsoniter_adapter_test.go #126 fix space in case map key is sorted 2017-07-11 01:07:18 +08:00
jsoniter_alias_test.go fix build; add document for exported symbols 2017-07-09 14:48:34 +08:00
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 import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
jsoniter_any_null_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
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 #133 validate json when Skip() 2017-07-18 09:45:25 +08:00
jsoniter_array_test.go #139 unmarshal non base64 into []byte 2017-07-19 12:04:22 +08:00
jsoniter_bool_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
jsoniter_customize_test.go #157 number can be null 2017-09-05 13:00:03 +08:00
jsoniter_demo_test.go fix go report card 2017-07-09 11:12:37 +08:00
jsoniter_encode_interface_test.go increase coverage 2017-07-13 15:32:26 +08:00
jsoniter_fixed_array_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
jsoniter_float_test.go #135 verify 1e1 and 1.0e1 is handled same as std 2017-07-18 11:28:19 +08:00
jsoniter_int_test.go #157 number can be null 2017-09-05 13:00:03 +08:00
jsoniter_interface_test.go #166 support ValidateJsonRawMessage in ConfigCompatibleWithStandardLibrary 2017-09-14 23:54:40 +08:00
jsoniter_invalid_test.go #157 number can be null 2017-09-05 13:00:03 +08:00
jsoniter_io_test.go #133 validate json when Skip() 2017-07-18 09:45:25 +08:00
jsoniter_iterator_test.go Use json.Number as the return 2017-07-12 00:11:50 +08:00
jsoniter_large_file_test.go #139 unmarshal non base64 into []byte 2017-07-19 12:04:22 +08:00
jsoniter_map_test.go #129 fix read map with reader, should use ReadMapCB instead of ReadObjectCB 2017-07-12 16:40:05 +08:00
jsoniter_must_be_valid_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
jsoniter_nested_test.go #68 number to string 2017-06-20 15:11:01 +08:00
jsoniter_null_test.go #133 fix empty struct skip; fix ] as empty array 2017-07-17 09:09:00 +08:00
jsoniter_object_test.go #142 decode struct field should be case insensitive, the bug only happen for struct with more than 10 fields 2017-07-31 20:50:07 +08:00
jsoniter_optional_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +08:00
jsoniter_raw_message_test.go #166 support ValidateJsonRawMessage in ConfigCompatibleWithStandardLibrary 2017-09-14 23:54:40 +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 #59 add ConfigFastest 2017-06-17 10:21:37 +08:00
jsoniter_skip_test.go implement skip number and string strictly 2017-07-18 09:01:43 +08:00
jsoniter_sloppy_test.go implement skip number and string strictly 2017-07-18 09:01:43 +08:00
jsoniter_stream_test.go import github.com/stretchr/testify/require 2017-07-07 09:13:25 +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_wrap_test.go rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08: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
README.md add ad 2017-07-31 21:49:02 +08:00
test.sh make test faster 2017-07-15 18:09:06 +08:00
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"

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"
jsoniter.Marshal(&data)

Replace

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

with

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