1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00
Commit Graph

808 Commits

Author SHA1 Message Date
10b9ac0971 std: float64/32 clean up e-09 to e-9 2022-09-15 21:13:32 +08:00
bf8b920736 Merge pull request #628 from HassanBaker/upgrade-stretchr
bumped stretchr to v1.8.0 to get rid of yaml v2 vuln
2022-08-05 15:01:11 +08:00
a7b8414362 bumped stretchr to v1.8.0 to get rid of yaml v2 vuln
Signed-off-by: Hassan Baker <me@hassanbaker.dev>
2022-08-04 17:25:33 +01:00
024077e996 fix go 1.18 compatibility v1.1.12 2021-09-11 10:17:26 +08:00
08b5e5796b notice incompatibility 2021-09-10 23:54:13 +08:00
c6661824eb Merge pull request #562 from runzhi/master
fix: invalid unicode while binary to string
2021-07-22 09:00:26 +08:00
3c55efb1a1 fix: invalid unicode while binary to string 2021-07-19 13:58:16 +08:00
e6b9536d36 Merge pull request #513 from AllenX2018/fix-issue-510
fix issue 510
v1.1.11
2020-11-18 09:31:58 +08:00
a3465d79a9 fix issue 510 2020-11-17 17:37:55 +08:00
9b79a3e192 fix issue 508 (#512) 2020-11-14 09:45:31 +08:00
1779031cda fix issue 508 2020-11-13 15:58:42 +08:00
6821bec9fa jsoniter: Fix errors during reading integers from chunked io.Reader (#477)
This commit fixes bug in Iterator.assertInteger method if the next
conditions are met:
- Iterator reads data from `io.Reader`,
- expected value is `0` (zero)
- `Iterator.tail == Iterator.head + 1`
- `Iterator.tail < len(Iterator.buf)`
- value in the buffer after `Iterator.tail` is presented from the previous read and has '.' character.

Typical error which user cal see is:
- assertInteger: can not decode float as int, error found in #X byte of ...

Regression test added for checking the correct behaviour.

Fixes #476
2020-08-06 09:14:08 +08:00
9461257643 fixed null in number json tag string (#480) 2020-08-03 10:12:41 +08:00
5bce16d299 fix issue #469 2020-07-21 17:07:23 +08:00
yjh
a1ca083078 update readme (#464) v1.1.10 2020-06-08 10:58:30 +08:00
cd6773e694 remove quotation check for key when decoding map
we don't need to check if the key is surrounded by quotation.
In fact, the key might not be strings if we register an extension to
customize the map key encoder/decoder.It may be an integer, float, or
even a struct.
2020-05-31 18:18:48 +08:00
55287ed53a disable map_key_test temporarily
- disable this test until golang issue 38105&38940 is fixed
2020-05-08 15:08:25 +08:00
8961be9c21 Map keys of custom types should serialize using MarshalText when available (#461)
* Map keys of custom types should serialize/deserialize using MarshalText/UnmarshalText when available

- this brings marshaling/unmarshaling behavior in line with encoding/json
- in general, any types that implement the interfaces from the encoding package (TextUnmarshaler, TextMarshaler, etc.) should use the provided method when available
2020-05-08 10:21:59 +08:00
0f8241d334 Merge pull request #441 from robfig/flush2
(*Stream).WriteMore: do not Flush
2020-04-29 14:50:44 +08:00
53b9d06ba7 temporarily comment out some test case to fix the CI fail since go1.14 released 2020-03-30 16:42:45 +08:00
1f7ee05ef8 Merge pull request #433 from AllenX2018/fix-anonymous-struct-error-message
fix issue #421
2020-03-30 16:26:14 +08:00
b22f393858 Merge pull request #450 from fantastao/fix_any_str_panic
fix any str ToInt64 ToUint64 panic
2020-03-26 19:37:32 +08:00
bede7b9e40 fix any str ToInt64 ToUint64 panic
Change-Id: Ic1690713d96940258811cdc149b1604128aa91a2
2020-03-26 18:17:29 +08:00
58aeb59006 fix issue #449 2020-03-26 14:46:47 +08:00
7acbb404a4 Merge pull request #432 from AllenX2018/fix-raw-message-integer-issue
fix issue #389 #411
2020-02-06 09:56:04 +08:00
69f2a91ff4 Merge pull request #429 from AllenX2018/fix-typo
fix issue #326
2020-02-05 09:51:54 +08:00
11a37a0774 (*Stream).WriteMore: remove implicit Flush
I believe that WriteMore should not call Flush for these reasons:

1. This is surprising for users because of inconsistency. Why call Flush in
   WriteMore and not in WriteObjectEnd?

2. It is not necessary; callers are free to call Flush if their use case demands
   it.

3. It harms performance in the common case by flushing the buffer much more
   frequently than it needs to be flushed.

The stream benchmark shows a 7% benefit to removing the Flush call, and I
observed a similar speedup in my real-world use case.

    benchmark                                        old ns/op     new ns/op     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     442           437           -1.13%
    Benchmark_jsoniter_large_file-8                  21222         21062         -0.75%
    Benchmark_json_large_file-8                      40187         40266         +0.20%
    Benchmark_stream_encode_big_object-8             8611          7956          -7.61%

    benchmark                                        old allocs     new allocs     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     6              6              +0.00%
    Benchmark_jsoniter_large_file-8                  78             78             +0.00%
    Benchmark_json_large_file-8                      13             13             +0.00%
    Benchmark_stream_encode_big_object-8             0              0              +0.00%

    benchmark                                        old bytes     new bytes     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     760           760           +0.00%
    Benchmark_jsoniter_large_file-8                  4920          4920          +0.00%
    Benchmark_json_large_file-8                      6640          6640          +0.00%
    Benchmark_stream_encode_big_object-8             0             0             +0.00%

Backwards compatibility - I believe there is little to no risk that this breaks
callers. WriteMore does not leave the JSON in a valid state, so it must be
followed by other Write* methods. To get the finished JSON out, the caller must
already be calling Flush.
2020-01-17 22:14:50 -05:00
91f4a6405d (*Stream).Flush: reset buffer to beginning
Previously it would append to the end of the buffer instead of reusing the
now-free space.

Benchmark demonstrates the improvement, run with -benchtime=10s

    benchmark                                        old ns/op     new ns/op     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     447           442           -1.12%
    Benchmark_jsoniter_large_file-8                  20998         21222         +1.07%
    Benchmark_json_large_file-8                      39593         40187         +1.50%
    Benchmark_stream_encode_big_object-8             10787         8611          -20.17%

    benchmark                                        old allocs     new allocs     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     6              6              +0.00%
    Benchmark_jsoniter_large_file-8                  78             78             +0.00%
    Benchmark_json_large_file-8                      13             13             +0.00%
    Benchmark_stream_encode_big_object-8             31             0              -100.00%

    benchmark                                        old bytes     new bytes     delta
    Benchmark_encode_string_with_SetEscapeHTML-8     760           760           +0.00%
    Benchmark_jsoniter_large_file-8                  4920          4920          +0.00%
    Benchmark_json_large_file-8                      6640          6640          +0.00%
    Benchmark_stream_encode_big_object-8             10056         0             -100.00%

Fixes #438
2020-01-17 21:57:59 -05:00
a54d350455 benchmarks: add benchmark for Stream 2020-01-17 16:50:46 -05:00
6f4c196d95 add more testcase 2020-01-16 17:17:18 +08:00
8302a17e8c fix issue #421 2020-01-15 20:21:20 +08:00
3987001e27 fix issue #389 #411 2020-01-14 14:14:02 +08:00
78d9e97b7a fix issue #326 2020-01-10 16:11:04 +08:00
49c900ee46 Merge pull request #427 from AllenX2018/fix-typo
fix the error message typo of ReadObjectCB & ReadMapCb function
2020-01-06 10:38:24 +08:00
9c0685d8d3 fix the error message typo of ReadObjectCB & ReadMapCb function 2020-01-03 15:31:12 +08:00
acfec88f7a Merge pull request #422 from JensErat/map-invalid-type
pass nested error in compatible configuration, fixes #388
v1.1.9
2019-12-21 11:10:28 +08:00
e88512faf8 Merge pull request #423 from vano144/fix-attachments-on-stream
fix nil attachment on stream in custom encoder on sorted map
2019-12-21 11:09:53 +08:00
b681149eae Merge pull request #424 from aaronbee/sortKeysMapAllocations
Reduce allocations in sortKeysMapEncoder
2019-12-21 11:09:15 +08:00
d1af7639b3 Merge pull request #425 from liggitt/default-max-depth
Revert "Merge pull request #418 from bbrks/configurable_maxDepth"
2019-12-21 11:04:54 +08:00
7c9f8c2d20 Revert "Merge pull request #418 from bbrks/configurable_maxDepth"
This reverts commit 44a7e7340d, reversing
changes made to dc11f49689.
2019-12-19 19:06:29 -05:00
f814d6c0f1 Reduce allocations in sortKeysMapEncoder
Use one buffer for all values.
2019-12-03 11:55:47 -08:00
aba8654400 fix nil attachment on stream in custom encoder on sorted map 2019-11-28 17:39:42 +03:00
a1c9557592 pass nested error in compatible configuration
When invalid types inside a map were marshalled (in general, as soon as
sorted maps have been configured), the error message has not been
propagated out of the map's `subStream`.

Also fix and re-enable the channel test, which now resembles the
behavior of `encoding/json` and tests both default and compatible
configurations.

Signed-off-by: Jens Erat <email@jenserat.de>
2019-11-22 16:56:59 +01:00
44a7e7340d Merge pull request #418 from bbrks/configurable_maxDepth
Add MaxDepth as a config option
2019-11-12 22:47:28 +08:00
2834c7e43c Remove large test values that fail on 32-bit architectures 2019-11-11 16:35:50 +00:00
d296277d5c Adds MaxDepth config option
Defaults to 10,000 to match the existing maxDepth constant everywhetre,
except when using `ConfigCompatibleWithStandardLibrary` - which retains
the limitless depth (and causes a stack overflow).

Added tests for the new config, and also up to jsoniter's stack overflow limit.
2019-11-11 16:13:59 +00:00
dc11f49689 Merge pull request #416 from jarredhawkins/issue-415
Ignore unnamed literals in structs
2019-10-30 08:35:33 +08:00
83f7b825b3 Unnamed struct literals 2019-10-28 23:05:10 -07:00
03217c3e97 Merge pull request #410 from liggitt/stack
Limit nesting depth
v1.1.8 1.1.8
2019-10-12 21:07:04 +08:00
908eaed151 Merge pull request #408 from onelrdm/master
skip - tag before spliting parts
2019-10-12 21:05:04 +08:00