commit | 6821bec9fa5c17f697f0f2f77ac5055e41a203ac | [log] [tgz] |
---|---|---|
author | Ivan Boyarkin <mr.Vanboy@gmail.com> | Thu Aug 06 01:14:08 2020 |
committer | GitHub <noreply@github.com> | Thu Aug 06 01:14:08 2020 |
tree | 0e9a7b9fd46dce402387202ad9148fa745127a24 | |
parent | 9461257643af4e53139afb97f3b4b6144cf8327b [diff] |
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
A high-performance 100% compatible drop-in replacement of “encoding/json”
You can also use thrift like JSON using thrift-iterator
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.
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)
go get github.com/json-iterator/go
Contributors
Report issue or pull request, or email taowen@gmail.com, or