1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
Commit Graph

774 Commits

Author SHA1 Message Date
Tao Wen
eb9aeccee2 consolidate builtin tests 2018-02-13 15:48:39 +08:00
Tao Wen
28adca2a14 consolidate array test 2018-02-13 15:43:10 +08:00
Tao Wen
a9b3f36b2f add test framework 2018-02-13 15:32:21 +08:00
Brian Brazil
1e8e785321 Remove allocs from WriteFloat32/WriteFloat64
The use of strconv.FormatFloat causes a string allocation,
by setting aside a reusable buffer and using strconv.AppendFloat
this can be avoided.

Before:
BenchmarkRespond-4           300           5392189 ns/op          618936 B/op      20010 allocs/op

After:
BenchmarkRespond-4           300           4713746 ns/op          139744 B/op         10 allocs/op

This benchmark is using a custom encoder that calls WriteFloat64 20k
times, which is the bulk of the work.
2018-02-07 17:30:57 +00:00
Tao Wen
002b5ae342 fix tests 2018-02-05 23:45:42 +08:00
Tao Wen
07f99a1124 fix build 2018-02-05 23:05:57 +08:00
Tao Wen
71f74dc71e implement #230 DisallowUnknownFields option added 2018-02-05 23:03:53 +08:00
Tao Wen
7990317be5 gofmt 2018-02-05 22:45:04 +08:00
Tao Wen
9edd73f752 fix build 2018-02-05 22:26:39 +08:00
Tao Wen
3d5ee1098a Merge branch 'master' of https://github.com/json-iterator/go 2018-02-05 21:43:52 +08:00
Tao Wen
ee8cfb7547 cache frozenConfig 2018-02-05 21:43:37 +08:00
Tao Wen
bca911dae0
Update README.md 2018-01-28 22:27:09 +08:00
Tao Wen
28452fcdec cow cache is not same, as map read will modify the underlying map. use sync.Map for 1.9 and above, and mutex if sync.Map not available 2018-01-28 17:00:11 +08:00
Tao Wen
ea8c33040f fix #228 2018-01-27 16:25:48 +08:00
Tao Wen
358cfc3929 Merge branch 'master' of https://github.com/json-iterator/go 2018-01-25 14:48:02 +08:00
Tao Wen
c39a632e65 fix #227, fix empty json.Number 2018-01-25 14:47:50 +08:00
Tao Wen
e31252f2e2
Merge pull request #225 from mgood/empty-array-fix
Fix encoding 0-length arrays
2018-01-23 23:31:07 +08:00
Matt Good
807e4a8b20 Optimize 0-length array case
Instead of checking the array length in encode, this can be checked up
front in `encoderOfArray` since the array type has a fixed length
determined at compile time. So return an `emptyArrayEncoder` that simply
writes an empty array to the stream.
2018-01-22 14:03:50 -08:00
Tao Wen
e78b7e89b6 Merge branch 'master' of https://github.com/json-iterator/go 2018-01-21 20:59:32 +08:00
Tao Wen
945d1aaa19 fix #140 uintptr will no lock the address from gc 2018-01-21 20:59:18 +08:00
Matt Good
ba3857729b Fix encoding 0-length arrays
The array encoder assumed that arrays had at least one value, so it
would serialize them with a zero-value for the array, such as `[0]`.

This adds a test to reproduce the issue, and updates the encoder to
write an empty array if the length is 0.
2018-01-16 11:02:03 -08:00
Tao Wen
c3ed5e85e0
Merge pull request #222 from neverlee/mydev
加入一个OnlyTaggedField选项
2018-01-09 18:30:25 +08:00
李盼
c27f6f9350 config: add OnlyTaggedField config, only process tagged fields in struct 2018-01-09 17:29:47 +08:00
Tao Wen
0ab880662f fix #219 should check real value for empty instead of just the pointer for nested field 2018-01-07 13:57:46 +08:00
Tao Wen
6dad2de6cc fix build 2018-01-04 17:18:16 +08:00
Tao Wen
11c1cce0d8 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
Tao Wen
96fcb84835 fix #215 lazy load more 2017-12-23 10:52:17 +08:00
Tao Wen
e7a8aea845 Merge branch 'master' of https://github.com/json-iterator/go 2017-12-21 22:18:40 +08:00
Tao Wen
60a9df5ebc fix #214 report EOF like stdlib 2017-12-21 22:18:28 +08:00
Tao Wen
7b060ec866
Merge pull request #210 from coocood/master
add ReadNumber for Iterator.
2017-12-18 08:22:47 +09:00
Ewan Chou
25f147f530 add ReadNumber for Iterator. 2017-12-17 16:44:04 +08:00
Tao Wen
a9b9c73b4d fix #207 delay unsupported type error reporting 2017-12-15 10:13:11 +08:00
Tao Wen
e0df39fda2 fix #206, do not allow nil pointer as unmarshal input 2017-12-14 17:18:05 +08:00
Tao Wen
13f86432b8 do not use defer() in read int 2017-12-12 18:52:41 +08:00
Tao Wen
d2a7335211 fix #202 #203 #204 map encoder not proplery initialized 2017-12-08 21:18:59 +08:00
Tao Wen
b2a706d14b reverse last commit, need a better fix 2017-12-08 06:15:49 +08:00
Tao Wen
23078876c5 fix #203 consider MarshalJSON as non empty 2017-12-07 23:20:43 +08:00
Tao Wen
051434fab7 fix #198, use dep for vendoring 2017-11-30 10:42:24 +08:00
Tao Wen
be6688fc1a fix #200, do not use symbolic link in the code 2017-11-30 10:34:05 +08:00
Tao Wen
ff2b70c1db support config level extension 2017-11-23 00:09:35 +08:00
Tao Wen
f7279a603e fix out of range 2017-11-15 23:34:21 +08:00
Tao Wen
9f088cbcc4 fix #195 when decode float as int, report it clearly 2017-11-15 23:25:12 +08:00
Tao Wen
3c0e5762c4 fix #196 do not hard code 1 << 49 2017-11-15 23:15:31 +08:00
Tao Wen
d394a135a1 #197 fix place holder encoder to use EncodeInterface, WriteToStream is unsafe when the real encoder is unknown 2017-11-15 22:56:23 +08:00
Tao Wen
9fddff05f0 try to fix #194 with larger array 2017-11-11 08:31:44 +08:00
Tao Wen
b1b003864e expose OptionalEncoder&OptionalDecoder; add attachment to Stream&Iterator for customized decoder/encoder 2017-11-08 11:41:45 +08:00
Tao Wen
aed5a81f09 fix #190 handle empty input 2017-10-31 22:47:02 +08:00
Tao Wen
f1258b01aa fix #191 do not always assume the object field is simple string 2017-10-31 22:38:41 +08:00
Tao Wen
fbd210edfc Merge pull request #189 from ggaaooppeenngg/compatible-with-map
Fix standard compatiblility
2017-10-26 18:39:38 -05:00
Peng Gao
640251ab91 Fix standard compatiblility
Non-nil but empty map with omitempty should be ignored.

Signed-off-by: Peng Gao <peng.gao.dut@gmail.com>
2017-10-27 01:43:41 +08:00