A high-performance 100% compatible drop-in replacement of "encoding/json"

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

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

Always benchmark with your own workload. The result depends heavily on the data input.

Usage

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)

More documentation

How to get

go get github.com/json-iterator/go

Contribution Welcomed !

Contributors

Report issue or pull request, or email [email protected], or Gitter chat

Owner
Jsoniter
Jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Jsoniter
Comments
  • decode number to interface{} as int64 rather than float64

    decode number to interface{} as int64 rather than float64

    I have a case where I need to decode into an interface{} as an int64, rather than float64. Is there a way to request that? Ideally it would be automatic - if the encoded value is a whole number, use int64, else use float64.

    stdlib has decoder.UseNumber which is closer to what we need...

  • 数组解析貌似有bug吖~~

    数组解析貌似有bug吖~~

    {"Info":{"InfoHash":"YWIlITn0T6UDgTqr8B8OLgC+mkw=","InfoHashstr":"6162252139F44FA503813AABF01F0E2E00BE9A4C","AnnounceList":null,"Length":7355754008,"PieceSize":8388608,"PieceNum":877},"InfoHashstr":"6162252139F44FA503813AABF01F0E2E00BE9A4C","SectionNum":40,"PieceNum":880,"PieceSize":16384,"Finished":false,"SparseSize":104857600,"Bit":[{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="},{"Size":880,"EndIndex":-1,"EndMask":0,"Good":0,"Flush":false,"Bit":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="}]}

    上面这段json, 外层的Bit数组一共有40个,解析时,到第17个数组就结束了,后续就跟着报错啦. 在ReadArray中看到是 case 'n' 返回false, 结束数组解析.

  • 大量请求时,内存泄漏问题

    大量请求时,内存泄漏问题

    目前我有一个项目,每天晚上需要更新大量的数据约300W条数据。通过更新发现内存会越来越大。

    我写了个testing.更新100000条数据。最后内存的结果为: image

    随着更新的数据越来越多,github.com/json-iterator/go.(*Iterator).readStringSlowPath 占用的内存会越来越大。

    请帮忙看一下是什么原因?谢谢

  • Using strings.Builder in golang v1.10 to reduce memory allocations

    Using strings.Builder in golang v1.10 to reduce memory allocations

    According issue #240 , there is no reason why we don't, so I've tried.

    And we are facing the real problems, the json.Unmarshal has been in our service's hot path. The Iterator.ReadString and Iterator.readStringSlowPath has been called multiple times per second. Any reasonable patch which could reduce the memory allocation will be valuable.

    I've tried to avoid to use any incompatible trick of Golang. So if there is any plan to support new features of golang v1.10, this PR should be helpful I think.

  • "found bad pointer in Go heap" when under load with large file

    Summary

    I'm getting an error from the garbage collector when I try json-iterator under load. I'm unmarshalling a large JSON file (2.7MB) repeatedly during a test into a regular struct. When the test is run with a long duration (=load), like -test.benchtime 10s, the test will fail while the minio server panics with the output below.

    I'm not sure where the problem is but I'd be very grateful for some assistance.

    Setup

    $ go version
    go version go1.7.6 linux/amd64
    $ uname -a
    Linux ... 4.10.0-24-generic #28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    

    The server has the jsoniter integration. It's in a PR (https://github.com/minio/minio/pull/4692). The integration is simple: https://github.com/brendanashworth/minio/commit/035bd53d12c1aa21b92cebbc7faf32f01ed91621. The JSON is retrieved and unmarshalled from multiple disks.

    Runtime panic

    runtime: pointer 0xc420a04000 to unallocated spanidx=0x502 span.base()=0xc4209e6000 span.limit=0xc420a06000 span.state=2
    runtime: found in object at *(0xc4221f0000+0x126b0)
    object=0xc4221f0000 k=0x62110f8 s.base()=0xc4221f0000 s.limit=0xc42227ba40 s.sizeclass=0 s.elemsize=573440
     *(object+0) = 0xc422366000
     *(object+8) = 0x6
     *(object+16) = 0xc422366006
     *(object+24) = 0x7
     *(object+32) = 0xc42182a000
     *(object+40) = 0x80
     *(object+48) = 0xc422366010
     *(object+56) = 0x6
     *(object+64) = 0xc422366016
     *(object+72) = 0x7
     *(object+80) = 0xc42182a080
     *(object+88) = 0x80
     *(object+96) = 0xc422366020
     *(object+104) = 0x6
     *(object+112) = 0xc422366026
     *(object+120) = 0x7
     *(object+128) = 0xc42182a200
     *(object+136) = 0x80
     *(object+144) = 0xc422366030
     *(object+152) = 0x6
     *(object+160) = 0xc422366036
     *(object+168) = 0x7
     *(object+176) = 0xc42182a280
     *(object+184) = 0x80
     *(object+192) = 0xc422366040
     *(object+200) = 0x6
     *(object+208) = 0xc422366046
     *(object+216) = 0x7
     *(object+224) = 0xc42182a300
     *(object+232) = 0x80
     *(object+240) = 0xc422366050
     *(object+248) = 0x6
     *(object+256) = 0xc422366056
     *(object+264) = 0x7
     *(object+272) = 0xc42182a380
     *(object+280) = 0x80
     *(object+288) = 0xc422366060
     *(object+296) = 0x6
     *(object+304) = 0xc422366066
     *(object+312) = 0x7
     *(object+320) = 0xc42182a400
     *(object+328) = 0x80
     *(object+336) = 0xc422366070
     *(object+344) = 0x6
     *(object+352) = 0xc422366076
     *(object+360) = 0x7
     *(object+368) = 0xc42182a480
     *(object+376) = 0x80
     *(object+384) = 0xc422366080
     *(object+392) = 0x6
     *(object+400) = 0xc422366086
     *(object+408) = 0x7
     *(object+416) = 0xc42182a500
     *(object+424) = 0x80
     *(object+432) = 0xc422366090
     *(object+440) = 0x7
     *(object+448) = 0xc422366097
     *(object+456) = 0x7
     *(object+464) = 0xc42182a580
     *(object+472) = 0x80
     *(object+480) = 0xc4223660a0
     *(object+488) = 0x7
     *(object+496) = 0xc4223660a7
     *(object+504) = 0x7
     *(object+512) = 0xc42182a600
     *(object+520) = 0x80
     *(object+528) = 0xc4223660b0
     *(object+536) = 0x7
     *(object+544) = 0xc4223660b7
     *(object+552) = 0x7
     *(object+560) = 0xc42182a680
     *(object+568) = 0x80
     *(object+576) = 0xc4223660c0
     *(object+584) = 0x7
     *(object+592) = 0xc4223660c7
     *(object+600) = 0x7
     *(object+608) = 0xc42182a700
     *(object+616) = 0x80
     *(object+624) = 0xc4223660d0
     *(object+632) = 0x7
     *(object+640) = 0xc4223660d7
     *(object+648) = 0x7
     *(object+656) = 0xc42182a780
     *(object+664) = 0x80
     *(object+672) = 0xc4223660e0
     *(object+680) = 0x7
     *(object+688) = 0xc4223660e7
     *(object+696) = 0x7
     *(object+704) = 0xc42182a800
     *(object+712) = 0x80
     *(object+720) = 0xc4223660f0
     *(object+728) = 0x7
     *(object+736) = 0xc4223660f7
     *(object+744) = 0x7
     *(object+752) = 0xc42182a880
     *(object+760) = 0x80
     *(object+768) = 0xc422366100
     *(object+776) = 0x7
     *(object+784) = 0xc422366107
     *(object+792) = 0x7
     *(object+800) = 0xc42182a900
     *(object+808) = 0x80
     *(object+816) = 0xc422366110
     *(object+824) = 0x7
     *(object+832) = 0xc422366117
     *(object+840) = 0x7
     *(object+848) = 0xc42182a980
     *(object+856) = 0x80
     *(object+864) = 0xc422366120
     *(object+872) = 0x7
     *(object+880) = 0xc422366127
     *(object+888) = 0x7
     *(object+896) = 0xc42182aa00
     *(object+904) = 0x80
     *(object+912) = 0xc422366130
     *(object+920) = 0x7
     *(object+928) = 0xc422366137
     *(object+936) = 0x7
     *(object+944) = 0xc42182aa80
     *(object+952) = 0x80
     *(object+960) = 0xc422366140
     *(object+968) = 0x7
     *(object+976) = 0xc422366147
     *(object+984) = 0x7
     *(object+992) = 0xc42182ab00
     *(object+1000) = 0x80
     *(object+1008) = 0xc422366150
     *(object+1016) = 0x7
     ...
     *(object+75320) = 0x9
     *(object+75328) = 0xc4204312f9
     *(object+75336) = 0x7
     *(object+75344) = 0xc4209dff00
     *(object+75352) = 0x80
     *(object+75360) = 0xc420431300
     *(object+75368) = 0x9
     *(object+75376) = 0xc420431309
     *(object+75384) = 0x7
     *(object+75392) = 0xc4209dff80
     *(object+75400) = 0x80
     *(object+75408) = 0xc420431310
     *(object+75416) = 0x9
     *(object+75424) = 0xc420431319
     *(object+75432) = 0x7
     *(object+75440) = 0xc420a04000 <==
     *(object+75448) = 0x80
     *(object+75456) = 0xc420431320
     *(object+75464) = 0x9
     *(object+75472) = 0xc420431329
     *(object+75480) = 0x7
     *(object+75488) = 0xc420a04080
     *(object+75496) = 0x80
     *(object+75504) = 0xc420431330
     *(object+75512) = 0x9
     *(object+75520) = 0xc420431339
     *(object+75528) = 0x7
     *(object+75536) = 0xc420a04100
     *(object+75544) = 0x80
     *(object+75552) = 0xc420431340
     *(object+75560) = 0x9
     ...
    fatal error: found bad pointer in Go heap (incorrect use of unsafe or cgo?)
    
    goroutine 29 [running]:
    runtime.throw(0x105a5d5, 0x3e)
    	/root/go/src/runtime/panic.go:566 +0x95 fp=0xc420049e38 sp=0xc420049e18
    runtime.heapBitsForObject(0xc420a04000, 0xc4221f0000, 0x126b0, 0xc41ffde767, 0xc400000002, 0x7f47268e8dd0, 0xc420020728, 0x131)
    	/root/go/src/runtime/mbitmap.go:429 +0x2ba fp=0xc420049e90 sp=0xc420049e38
    runtime.scanobject(0xc4221f0000, 0xc420020728)
    	/root/go/src/runtime/mgcmark.go:1175 +0x170 fp=0xc420049f10 sp=0xc420049e90
    runtime.gcDrain(0xc420020728, 0x6)
    	/root/go/src/runtime/mgcmark.go:999 +0x15c fp=0xc420049f48 sp=0xc420049f10
    runtime.gcBgMarkWorker(0xc42001f500)
    	/root/go/src/runtime/mgc.go:1458 +0x4ad fp=0xc420049fb8 sp=0xc420049f48
    runtime.goexit()
    	/root/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc420049fc0 sp=0xc420049fb8
    created by runtime.gcBgMarkStartWorkers
    	/root/go/src/runtime/mgc.go:1349 +0x98
    
    goroutine 1 [select, 12 minutes]:
    github.com/minio/minio/cmd.handleSignals()
    	/root/gopath/src/github.com/minio/minio/cmd/signals.go:53 +0x607
    github.com/minio/minio/cmd.serverMain(0xc42030e160)
    	/root/gopath/src/github.com/minio/minio/cmd/server-main.go:223 +0x807
    github.com/minio/minio/vendor/github.com/minio/cli.HandleAction(0xe6e9c0, 0x10cd1d0, 0xc42030e160, 0xc4201a7900, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/minio/cli/app.go:499 +0x7c
    github.com/minio/minio/vendor/github.com/minio/cli.Command.Run(0x10251f0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x103f2fa, 0x1c, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/minio/cli/command.go:214 +0xb9a
    github.com/minio/minio/vendor/github.com/minio/cli.(*App).Run(0xc42019fba0, 0xc42000a0c0, 0x6, 0x6, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/minio/cli/app.go:260 +0x816
    github.com/minio/minio/cmd.Main(0xc42000a0c0, 0x6, 0x6)
    	/root/gopath/src/github.com/minio/minio/cmd/main.go:145 +0x8d
    main.main()
    	/root/gopath/src/github.com/minio/minio/main.go:68 +0x7b
    
    goroutine 17 [syscall, 12 minutes]:
    os/signal.signal_recv(0xc42004bfa8)
    	/root/go/src/runtime/sigqueue.go:116 +0x157
    os/signal.loop()
    	/root/go/src/os/signal/signal_unix.go:22 +0x22
    created by os/signal.init.1
    	/root/go/src/os/signal/signal_unix.go:28 +0x41
    
    goroutine 66 [IO wait]:
    net.runtime_pollWait(0x7f47268e7948, 0x72, 0x0)
    	/root/go/src/runtime/netpoll.go:160 +0x59
    net.(*pollDesc).wait(0xc4201a8290, 0x72, 0xc42004de78, 0xc4200141b0)
    	/root/go/src/net/fd_poll_runtime.go:73 +0x38
    net.(*pollDesc).waitRead(0xc4201a8290, 0x15bf440, 0xc4200141b0)
    	/root/go/src/net/fd_poll_runtime.go:78 +0x34
    net.(*netFD).accept(0xc4201a8230, 0x0, 0x15bc300, 0xc42215b5e0)
    	/root/go/src/net/fd_unix.go:419 +0x238
    net.(*TCPListener).accept(0xc42018a018, 0x433deb, 0xc42004df28, 0x914838)
    	/root/go/src/net/tcpsock_posix.go:132 +0x2e
    net.(*TCPListener).AcceptTCP(0xc42018a018, 0xc4201ea0c0, 0xc42018a030, 0xc420576060)
    	/root/go/src/net/tcpsock.go:209 +0x49
    github.com/minio/minio/pkg/http.(*httpListener).start.func3(0xc42018a018, 0xc420576060)
    	/root/gopath/src/github.com/minio/minio/pkg/http/listener.go:197 +0x41
    created by github.com/minio/minio/pkg/http.(*httpListener).start
    	/root/gopath/src/github.com/minio/minio/pkg/http/listener.go:211 +0x1cd
    
    goroutine 9 [select, 12 minutes, locked to thread]:
    runtime.gopark(0x10cf070, 0x0, 0x10251e4, 0x6, 0x18, 0x2)
    	/root/go/src/runtime/proc.go:259 +0x13a
    runtime.selectgoImpl(0xc420496730, 0x0, 0x18)
    	/root/go/src/runtime/select.go:423 +0x1235
    runtime.selectgo(0xc420496730)
    	/root/go/src/runtime/select.go:238 +0x1c
    runtime.ensureSigM.func1()
    	/root/go/src/runtime/signal1_unix.go:304 +0x2f3
    runtime.goexit()
    	/root/go/src/runtime/asm_amd64.s:2086 +0x1
    
    goroutine 8 [chan receive]:
    github.com/minio/minio/pkg/http.(*httpListener).Accept(0xc4201a82a0, 0x10ce9e0, 0xc420aaa280, 0x15c6c40, 0xc420450390)
    	/root/gopath/src/github.com/minio/minio/pkg/http/listener.go:217 +0x6d
    net/http.(*Server).Serve(0xc420315860, 0x15c3400, 0xc4201a82a0, 0x0, 0x0)
    	/root/go/src/net/http/server.go:2273 +0x1ce
    github.com/minio/minio/pkg/http.(*Server).Start(0xc420315860, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/pkg/http/server.go:116 +0x1cc
    github.com/minio/minio/cmd.serverMain.func1()
    	/root/gopath/src/github.com/minio/minio/cmd/server-main.go:199 +0x2d
    created by github.com/minio/minio/cmd.serverMain
    	/root/gopath/src/github.com/minio/minio/cmd/server-main.go:200 +0x62c
    
    goroutine 15 [select, 12 minutes]:
    github.com/minio/minio/pkg/objcache.(*Cache).StartGC.func1(0xc42069e060)
    	/root/gopath/src/github.com/minio/minio/pkg/objcache/objcache.go:295 +0x133
    created by github.com/minio/minio/pkg/objcache.(*Cache).StartGC
    	/root/gopath/src/github.com/minio/minio/pkg/objcache/objcache.go:304 +0x3f
    
    goroutine 84 [select, 12 minutes]:
    github.com/minio/minio/pkg/objcache.(*Cache).StartGC.func1(0xc42000a180)
    	/root/gopath/src/github.com/minio/minio/pkg/objcache/objcache.go:295 +0x133
    created by github.com/minio/minio/pkg/objcache.(*Cache).StartGC
    	/root/gopath/src/github.com/minio/minio/pkg/objcache/objcache.go:304 +0x3f
    
    goroutine 1243 [GC assist wait]:
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadString(0xc4204c2070, 0xc4204c2070, 0x552)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_iter_string.go:15 +0x1ce
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*stringCodec).Decode(0x187aeb8, 0xc4207dff38, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_native.go:15 +0x2b
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*structFieldDecoder).Decode(0xc420458b40, 0xc4207dff30, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:911 +0x5c
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*fourFieldsStructDecoder).Decode(0xc42045c0a0, 0xc4207dff30, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:577 +0x2aa
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode.func1(0xc4204c2070, 0xe5ad2c)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:101 +0xa1
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadArrayCB(0xc4204c2070, 0xc42267d830, 0xe5ad20)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_iter_array.go:39 +0xae
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode(0xc4204503c0, 0xc4200924c8, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:104 +0xe7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).Decode(0xc4204503c0, 0xc4200924c8, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:82 +0x49
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*structFieldDecoder).Decode(0xc420459440, 0xc420092410, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:911 +0x5c
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sevenFieldsStructDecoder).Decode(0xc420198600, 0xc420092410, 0xc4204c2070)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:705 +0x3a7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadVal(0xc4204c2070, 0xf09740, 0xc420092410)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect.go:216 +0xea
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc4201a6360, 0xc422e00000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420092410, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_config.go:283 +0x1ab
    github.com/minio/minio/vendor/github.com/json-iterator/go.Unmarshal(0xc422e00000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420092410, 0x1d, 0xc4217ac010)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_adapter.go:16 +0x67
    github.com/minio/minio/cmd.xlMetaV1UnmarshalJSON(0xc422e00000, 0x299cbb, 0x299ebb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:127 +0xae
    github.com/minio/minio/cmd.readXLMeta(0x15ccd80, 0xc420450810, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:151 +0x1a7
    github.com/minio/minio/cmd.readAllXLMetadata.func1(0xc420644ac0, 0xc4203ed880, 0x4, 0x4, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0xc420468c80, 0x4, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:181 +0xb1
    created by github.com/minio/minio/cmd.readAllXLMetadata
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:186 +0x2af
    
    goroutine 1241 [GC assist wait]:
    reflect.unsafe_NewArray(0xf67f40, 0x200, 0xf67f40)
    	/root/go/src/runtime/malloc.go:803 +0x35
    reflect.MakeSlice(0x15d00c0, 0xe5ad20, 0x101, 0x200, 0xe5ad20, 0xc4203e7a80, 0x97)
    	/root/go/src/reflect/value.go:2043 +0xe5
    github.com/minio/minio/vendor/github.com/json-iterator/go.growOne(0xc4203143f8, 0x15d00c0, 0xe5ad20, 0x15d00c0, 0xf67f40)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:127 +0x8a
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode.func1(0xc420454000, 0xc42031432c)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:100 +0x68
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadArrayCB(0xc420454000, 0xc420685830, 0xe5ad20)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_iter_array.go:39 +0xae
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode(0xc4204503c0, 0xc4203143f8, 0xc420454000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:104 +0xe7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).Decode(0xc4204503c0, 0xc4203143f8, 0xc420454000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:82 +0x49
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*structFieldDecoder).Decode(0xc420459440, 0xc420314340, 0xc420454000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:911 +0x5c
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sevenFieldsStructDecoder).Decode(0xc420198600, 0xc420314340, 0xc420454000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:705 +0x3a7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadVal(0xc420454000, 0xf09740, 0xc420314340)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect.go:216 +0xea
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc4201a6360, 0xc42184c000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420314340, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_config.go:283 +0x1ab
    github.com/minio/minio/vendor/github.com/json-iterator/go.Unmarshal(0xc42184c000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420314340, 0x1d, 0xc4217b0000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_adapter.go:16 +0x67
    github.com/minio/minio/cmd.xlMetaV1UnmarshalJSON(0xc42184c000, 0x299cbb, 0x299ebb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:127 +0xae
    github.com/minio/minio/cmd.readXLMeta(0x15ccd80, 0xc420450780, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:151 +0x1a7
    github.com/minio/minio/cmd.readAllXLMetadata.func1(0xc420644ac0, 0xc4203ed880, 0x4, 0x4, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0xc420468c80, 0x4, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:181 +0xb1
    created by github.com/minio/minio/cmd.readAllXLMetadata
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:186 +0x2af
    
    goroutine 1242 [GC assist wait]:
    reflect.unsafe_NewArray(0xf67f40, 0x200, 0xf67f40)
    	/root/go/src/runtime/malloc.go:803 +0x35
    reflect.MakeSlice(0x15d00c0, 0xe5ad20, 0x101, 0x200, 0xe5ad20, 0xc4203f5a20, 0x97)
    	/root/go/src/reflect/value.go:2043 +0xe5
    github.com/minio/minio/vendor/github.com/json-iterator/go.growOne(0xc4201383f8, 0x15d00c0, 0xe5ad20, 0x15d00c0, 0xf67f40)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:127 +0x8a
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode.func1(0xc4200720e0, 0xc42013832c)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:100 +0x68
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadArrayCB(0xc4200720e0, 0xc420aa9830, 0xe5ad20)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_iter_array.go:39 +0xae
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode(0xc4204503c0, 0xc4201383f8, 0xc4200720e0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:104 +0xe7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).Decode(0xc4204503c0, 0xc4201383f8, 0xc4200720e0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:82 +0x49
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*structFieldDecoder).Decode(0xc420459440, 0xc420138340, 0xc4200720e0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:911 +0x5c
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sevenFieldsStructDecoder).Decode(0xc420198600, 0xc420138340, 0xc4200720e0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:705 +0x3a7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadVal(0xc4200720e0, 0xf09740, 0xc420138340)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect.go:216 +0xea
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc4201a6360, 0xc42395e000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420138340, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_config.go:283 +0x1ab
    github.com/minio/minio/vendor/github.com/json-iterator/go.Unmarshal(0xc42395e000, 0x299cbb, 0x299ebb, 0xf09740, 0xc420138340, 0x1d, 0xc4217ae000)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_adapter.go:16 +0x67
    github.com/minio/minio/cmd.xlMetaV1UnmarshalJSON(0xc42395e000, 0x299cbb, 0x299ebb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:127 +0xae
    github.com/minio/minio/cmd.readXLMeta(0x15ccd80, 0xc4204507e0, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:151 +0x1a7
    github.com/minio/minio/cmd.readAllXLMetadata.func1(0xc420644ac0, 0xc4203ed880, 0x4, 0x4, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0xc420468c80, 0x4, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:181 +0xb1
    created by github.com/minio/minio/cmd.readAllXLMetadata
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:186 +0x2af
    
    goroutine 1240 [semacquire]:
    sync.runtime_Semacquire(0xc420644acc)
    	/root/go/src/runtime/sema.go:47 +0x30
    sync.(*WaitGroup).Wait(0xc420644ac0)
    	/root/go/src/sync/waitgroup.go:131 +0x97
    github.com/minio/minio/cmd.readAllXLMetadata(0xc420190680, 0x4, 0x4, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0xc420290c60, 0x2, 0x2, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:190 +0x2ed
    github.com/minio/minio/cmd.xlObjects.GetObject(0xc42045a638, 0xc420190680, 0x4, 0x4, 0x2, 0x2, 0x2, 0x3, 0xc42044e580, 0xc42000a180, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-object.go:153 +0x144
    github.com/minio/minio/cmd.(*xlObjects).GetObject(0xc4205760c0, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0x0, 0xc80000000, 0x15bd700, 0xc420468140, 0x1852c60, ...)
    	<autogenerated>:1052 +0xfa
    github.com/minio/minio/cmd.objectAPIHandlers.GetObjectHandler(0x10cd138, 0x15c33c0, 0xc42031a600, 0xc420130870)
    	/root/gopath/src/github.com/minio/minio/cmd/object-handlers.go:160 +0x606
    github.com/minio/minio/cmd.(objectAPIHandlers).GetObjectHandler-fm(0x15c33c0, 0xc42031a600, 0xc420130870)
    	/root/gopath/src/github.com/minio/minio/cmd/api-router.go:56 +0x4e
    net/http.HandlerFunc.ServeHTTP(0xc4204652b0, 0x15c33c0, 0xc42031a600, 0xc420130870)
    	/root/go/src/net/http/server.go:1726 +0x44
    github.com/minio/minio/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4201e03c0, 0x15c33c0, 0xc42031a600, 0xc420130870)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/gorilla/mux/mux.go:107 +0x10d
    github.com/minio/minio/cmd.pathValidityHandler.ServeHTTP(0x15b8f00, 0xc4201e03c0, 0x15c33c0, 0xc42031a600, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:470 +0x18b
    github.com/minio/minio/cmd.(*pathValidityHandler).ServeHTTP(0xc42044a2b0, 0x15c33c0, 0xc42031a600, 0xc4201305a0)
    	<autogenerated>:512 +0x79
    github.com/minio/minio/cmd.httpStatsHandler.ServeHTTP(0x15bd840, 0xc42044a2b0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:409 +0xcb
    github.com/minio/minio/cmd.(*httpStatsHandler).ServeHTTP(0xc42044a2c0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:511 +0x79
    github.com/minio/minio/cmd.requestSizeLimitHandler.ServeHTTP(0x15bd780, 0xc42044a2c0, 0x404000000, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:65 +0x100
    github.com/minio/minio/cmd.(*requestSizeLimitHandler).ServeHTTP(0xc420525380, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:503 +0x82
    github.com/minio/minio/cmd.crossDomainPolicy.ServeHTTP(0x15bd8c0, 0xc420525380, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/crossdomain-xml-handler.go:51 +0x65
    github.com/minio/minio/cmd.(*crossDomainPolicy).ServeHTTP(0xc42044a2d0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:347 +0x79
    github.com/minio/minio/cmd.redirectHandler.ServeHTTP(0x15bd6c0, 0xc42044a2d0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:131 +0xc0
    github.com/minio/minio/cmd.(*redirectHandler).ServeHTTP(0xc42044a2e0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:504 +0x79
    github.com/minio/minio/cmd.minioPrivateBucketHandler.ServeHTTP(0x15bd880, 0xc42044a2e0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:177 +0x90
    github.com/minio/minio/cmd.(*minioPrivateBucketHandler).ServeHTTP(0xc42044a2f0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:506 +0x79
    github.com/minio/minio/cmd.cacheControlHandler.ServeHTTP(0x15bd800, 0xc42044a2f0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:158 +0x60
    github.com/minio/minio/cmd.(*cacheControlHandler).ServeHTTP(0xc42044a300, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:505 +0x79
    github.com/minio/minio/cmd.timeValidityHandler.ServeHTTP(0x15bd680, 0xc42044a300, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:247 +0x1e9
    github.com/minio/minio/cmd.(*timeValidityHandler).ServeHTTP(0xc42044a310, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:507 +0x79
    github.com/minio/minio/vendor/github.com/rs/cors.(*Cors).Handler.func1(0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/rs/cors/cors.go:190 +0xe9
    net/http.HandlerFunc.ServeHTTP(0xc420525420, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/go/src/net/http/server.go:1726 +0x44
    github.com/minio/minio/cmd.resourceHandler.ServeHTTP(0x15be900, 0xc420525420, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/generic-handlers.go:360 +0xa2
    github.com/minio/minio/cmd.(*resourceHandler).ServeHTTP(0xc42044a390, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:508 +0x79
    github.com/minio/minio/cmd.authHandler.ServeHTTP(0x15bd900, 0xc42044a390, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/cmd/auth-handler.go:229 +0x157
    github.com/minio/minio/cmd.(*authHandler).ServeHTTP(0xc42044a3b0, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	<autogenerated>:288 +0x79
    github.com/minio/minio/pkg/http.(*Server).Start.func1(0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/gopath/src/github.com/minio/minio/pkg/http/server.go:107 +0x108
    net/http.HandlerFunc.ServeHTTP(0xc4201ea100, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/go/src/net/http/server.go:1726 +0x44
    net/http.serverHandler.ServeHTTP(0xc420315860, 0x15c5bc0, 0xc420138270, 0xc4201305a0)
    	/root/go/src/net/http/server.go:2202 +0x7d
    net/http.(*conn).serve(0xc420aaa280, 0x15c6b80, 0xc420469bc0)
    	/root/go/src/net/http/server.go:1579 +0x4b7
    created by net/http.(*Server).Serve
    	/root/go/src/net/http/server.go:2293 +0x44d
    
    goroutine 1244 [GC assist wait]:
    reflect.unsafe_NewArray(0xf67f40, 0xf42, 0xf67f40)
    	/root/go/src/runtime/malloc.go:803 +0x35
    reflect.MakeSlice(0x15d00c0, 0xe5ad20, 0xc36, 0xf42, 0xe5ad20, 0xc420447460, 0x97)
    	/root/go/src/reflect/value.go:2043 +0xe5
    github.com/minio/minio/vendor/github.com/json-iterator/go.growOne(0xc4218324c8, 0x15d00c0, 0xe5ad20, 0x15d00c0, 0xf67f40)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:127 +0x8a
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode.func1(0xc420072a80, 0xe5ad2c)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:100 +0x68
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadArrayCB(0xc420072a80, 0xc422681830, 0xe5ad20)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_iter_array.go:39 +0xae
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).doDecode(0xc4204503c0, 0xc4218324c8, 0xc420072a80)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:104 +0xe7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sliceDecoder).Decode(0xc4204503c0, 0xc4218324c8, 0xc420072a80)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_slice.go:82 +0x49
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*structFieldDecoder).Decode(0xc420459440, 0xc421832410, 0xc420072a80)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:911 +0x5c
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*sevenFieldsStructDecoder).Decode(0xc420198600, 0xc421832410, 0xc420072a80)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect_struct_decoder.go:705 +0x3a7
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*Iterator).ReadVal(0xc420072a80, 0xf09740, 0xc421832410)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_reflect.go:216 +0xea
    github.com/minio/minio/vendor/github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc4201a6360, 0xc423bf8000, 0x299cbb, 0x299ebb, 0xf09740, 0xc421832410, 0x0, 0x0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_config.go:283 +0x1ab
    github.com/minio/minio/vendor/github.com/json-iterator/go.Unmarshal(0xc423bf8000, 0x299cbb, 0x299ebb, 0xf09740, 0xc421832410, 0x1d, 0xc420644ae0)
    	/root/gopath/src/github.com/minio/minio/vendor/github.com/json-iterator/go/feature_adapter.go:16 +0x67
    github.com/minio/minio/cmd.xlMetaV1UnmarshalJSON(0xc423bf8000, 0x299cbb, 0x299ebb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:127 +0xae
    github.com/minio/minio/cmd.readXLMeta(0x15ccd80, 0xc420450840, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0x0, 0x0, 0x0, 0x0, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:151 +0x1a7
    github.com/minio/minio/cmd.readAllXLMetadata.func1(0xc420644ac0, 0xc4203ed880, 0x4, 0x4, 0xc4207cfc65, 0x9, 0xc4207cfc6f, 0x3, 0xc420468c80, 0x4, ...)
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:181 +0xb1
    created by github.com/minio/minio/cmd.readAllXLMetadata
    	/root/gopath/src/github.com/minio/minio/cmd/xl-v1-utils.go:186 +0x2af
    
  • Don't marshal empty byte or uint8 slice as null

    Don't marshal empty byte or uint8 slice as null

    Fixes https://github.com/json-iterator/go/issues/272

    []byte or []uint8 are encoded as base-64 encoded strings. So, only nil slices of these types should get marshalled as null, and non-nil empty slices should get marshalled as "".

    This restores compatibility with the standard library.

    I verified that this patch works locally. Even though tests for these exist in https://github.com/json-iterator/go/blob/master/type_tests/slice_test.go, I couldn't reproduce a case where the test case was fuzzed to an empty []byte or []uint8 slice... :confused:

    /cc @taowen @thockin fyi @liggitt @dims @neolit123

  • Fix case sensitivity

    Fix case sensitivity

    Fixes https://github.com/kubernetes/kubernetes/issues/64612#issuecomment-396097020 Follow-up for https://github.com/json-iterator/go/pull/282

    Also see https://github.com/json-iterator/go/pull/282/files#r194283181

  • marshalled results not sorted same as stdlib

    marshalled results not sorted same as stdlib

    	json_test.go:29: marshal expected:
    		    {
    		    >  "-1538202063": 0.3634222946643717,
    		    >  "1223101607": 0.16867633434109314,
    		    >  "576443938": 0.020297602318735935
    		    }
    		got:
    		    {
    		    >  "576443938": 0.020297602318735935,
    		    >  "1223101607": 0.16867633434109314,
    		    >  "-1538202063": 0.3634222946643717
    		    }
    

    This is sort of tedious, but being exactly compatible has some value, right?

  • duplicate keys in json

    duplicate keys in json

    when I tried to parse the json from valve's web api, there are some duplicate keys in it. encoding/json seems not work. Can 'json-iterator' deal with this condition? json example:
    see https://github.com/Katsusan/go-dota2/blob/master/livinggames.json

    "abilities":[  // <-这样的"abilities"键总共有 0-5 个(代表 各个dota2英雄的技能升级情况)
    {
    "ability_id":5106,   //唯一技能 ID
    "ability_level":2  //技能等级
    },
    {
    "ability_id":5107,
    "ability_level":3
    }
    ]
    ,
    "abilities":[
    {
    "ability_id":5082,
    "ability_level":3
    },
    {
    "ability_id":5083,
    "ability_level":2
    }
    ]
    ,
    "abilities":[
    {
    "ability_id":5122,
    "ability_level":3
    },
    {
    "ability_id":5123,
    "ability_level":2
    },
    {
    "ability_id":5125,
    "ability_level":1
    }
    ]
    
  • []byte marshaled to null

    []byte marshaled to null

    One of the fuzz tests in Kubernetes caught an issue: This library:

    {"metadata":{"selfLink":"Ǭ`/F苫ŽȢ噯榋C","resourceVersion":"4597642297830476577"},"items":[{"metadata":{"name":"玿j情1 蔝","generateName":"萀枦đ ","uid":".愥+ǽķ蓧u岏V","resourceVersion":"13323996552230461162","creationTimestamp":null},"data":{"輣 兀zʩL:Ģ梸ïĭ":"MŞFƤ趻Ă癆萃猷S幸4"},"binaryData":{"Ȟ櫤薯WDZĥȂ":null}}]}
    

    encoding/json:

    {"metadata":{"selfLink":"Ǭ`/F苫ŽȢ噯榋C","resourceVersion":"4597642297830476577"},"items":[{"metadata":{"name":"玿j情1 蔝","generateName":"萀枦đ ","uid":".愥+ǽķ蓧u岏V","resourceVersion":"13323996552230461162","creationTimestamp":null},"data":{"輣 兀zʩL:Ģ梸ïĭ":"MŞFƤ趻Ă癆萃猷S幸4"},"binaryData":{"Ȟ櫤薯WDZĥȂ":""}}]}
    

    Notice how at the very end of the json the value in the map is not the same. BinaryData field is declared like this:

    BinaryData map[string][]byte `json:"binaryData,omitempty"`
    

    https://github.com/kubernetes/kubernetes/blob/8f20a815e5ef27d4d247e42bff90e42706397ca2/staging/src/k8s.io/api/core/v1/types.go#L4742

    Trying to migrate all encoding/json uses to this library in this PR https://github.com/kubernetes/kubernetes/pull/63284

    This is using commit 2ddf6d758266fcb080a4f9e054b9f292c85e6798

  • Bug with FuzzyDecoders

    Bug with FuzzyDecoders

    ReadMapCB: expect { or n, parsing 24 ...aders":{"f... at {"id":3160,"headers":{ .......

    type Email struct { Id uint64

    Encoding gomail.Encoding
    Charset  string
    
    Headers     map[string]utility.StringArray
    Body        EmailBody
    Alternative []EmailBody
    Attachment  map[string]EmailBody
    
    UserData map[string]interface{} `json:"user_data"`
    

    }

    It always stuck at reading Id, and if I put "id" at the end of JSON i got EOF

  • FATAL error:segmentation violation when marshal map

    FATAL error:segmentation violation when marshal map

    go version: go1.18.3

    test code:

    package main

    import ( "github.com/json-iterator/go" )

    func main() { var req = map[string]interface{}{ "a": "b", } jsoniter.Marshal(req) }

    got: unexpected fault address 0xb01dfacedebac1e fatal error: fault [signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x105b8df] ...

  • Why does stream.Write appends to stream.buf if stream.out is not nil?

    Why does stream.Write appends to stream.buf if stream.out is not nil?

    Hey, Thanks for writing this amazing library, I'm having a small thought about some allocation.

    Stream.Write appends to stream.buf even if stream.out is not nil, making it allocate (sometimes) extra slice even if it is not needed.

    this is the Write method:

    func (stream *Stream) Write(p []byte) (nn int, err error) {
    	stream.buf = append(stream.buf, p...)
    	if stream.out != nil {
    		nn, err = stream.out.Write(stream.buf)
    		stream.buf = stream.buf[nn:]
    		return
    	}
    	return len(p), nil
    }
    

    I do see that methods like WriteByte does only append, I guess it is to save overhead of small writings to io.Writer but in that case user can simply compose some chunkedStream (but will need to flush also outside stream)

    jsoniter.NewStream(SomeChunkedStreamThatFlushesEveryXBytes(theActualWriter))
    

    also, sometimes the writer is bytes.Buffer and in that case small writes are fine.

    Another option is maybe to add config KeepBuffer with default true to keep current behavior and not break anything and let the user decide, If you think this is good idea I'd gladly PR it.

    Would like to hear your opinion, thanks a lot

  • Anonymous field does not handle typeEncoders/typeDecoders

    Anonymous field does not handle typeEncoders/typeDecoders

    https://github.com/json-iterator/go/blob/e6b9536d3649bda3e8842bb7e4fab489d79a97ea/reflect_extension.go#L348-L375

    func TestAnonymous(t *testing.T) {
    	type Body struct {
    		Content string `json:"content"`
    	}
    
    	type Wrapper struct {
    		*Body
    		Other string `json:"other"`
    	}
    
    	jsoniter.RegisterTypeEncoderFunc("Body",
    		func(ptr unsafe.Pointer, stream *jsoniter.Stream) {
    			stream.WriteObjectStart()
    			stream.WriteObjectField("content")
    			stream.WriteString(((*Body)(ptr)).Content + "-fixed")
    			stream.WriteObjectEnd()
    		},
    		func(unsafe.Pointer) bool {
    			return false
    		},
    	)
    	w := Wrapper{
    		Body: &Body{
    			Content: "contentx",
    		},
    		Other: "otherx",
    	}
    	jsn, err := jsoniter.Marshal(w.Body)
    	if err != nil {
    		t.Fatal(err)
    	}
    	assert.Equal(t, `{"content":"contentx-fixed"}`, string(jsn))
    
    	jsn, err = jsoniter.Marshal(w)
    	if err != nil {
    		t.Fatal(err)
    	}
    	// !!! assert failed here
    	assert.Equal(t, `{"content":"contentx-fixed","other":"otherx"}`, string(jsn))
    }
    
  • jsoniter's Number is not strict compliance with JSON RFC 7159 standard

    jsoniter's Number is not strict compliance with JSON RFC 7159 standard

    version

    • go version go1.16.7 windows/amd64
    • github.com/json-iterator/go v1.1.12
    • github.com/stretchr/testify v1.3.0

    code to reproduce this issue

    package main
    
    import (
    	"bytes"
    	"encoding/json"
    	ejson "encoding/json"
    	"testing"
    
    	jsoniter "github.com/json-iterator/go"
    	"github.com/stretchr/testify/require"
    )
    
    func ijsonDecode(b []byte, pv interface{}) error {
    	ijson := jsoniter.ConfigCompatibleWithStandardLibrary
    	d := ijson.NewDecoder(bytes.NewReader(b))
    	d.UseNumber()
    	return d.Decode(pv)
    }
    
    func ejsonDecode(b []byte, pv interface{}) error {
    	d := ejson.NewDecoder(bytes.NewReader(b))
    	d.UseNumber()
    	return d.Decode(pv)
    }
    
    func TestJSONNumberDiffIE(t *testing.T) {
    	var cases = [][]byte{
    		[]byte(`{"a": 01}`),
    		[]byte(`{"a": 1.}`),
    		[]byte(`{"a": 1.e1}`),
    		[]byte(`{"a": -.1}`),
    	}
    	for _, b := range cases {
    		t.Logf("case: %v\n", string(b))
    		var iv, ev map[string]interface{}
    		ierr := ijsonDecode(b, &iv)
    		eerr := ejsonDecode(b, &ev)
    		t.Logf("ijson value: %v, error: %v\n", iv, ierr)
    		t.Logf("ejson value: %v, error: %v\n", ev, eerr)
    		require.NoError(t, ierr) // assert ijson accept it
    		require.Error(t, eerr)   // assert ejson reject it
    		var inum = iv["a"].(json.Number)
    		i64, i64err := inum.Int64()
    		f64, f64err := inum.Float64()
    		t.Logf("ijson Number: i64: %d, i64err: %v", i64, i64err)
    		t.Logf("ijson Number: f64: %f, f64err: %v", f64, f64err)
    		// assert ijson's Number meets the golang strconv standard
    		require.True(t, i64err == nil || f64err == nil)
    	}
    }
    

    console output

    $ go test -v -count=1 json_test.go -run TestJSONNumberDiffIE
    === RUN   TestJSONNumberDiffIE
        json_test.go:34: case: {"a": 01}
        json_test.go:38: ijson value: map[a:01], error: <nil>
        json_test.go:39: ejson value: map[], error: invalid character '1' after object key:value pair
        json_test.go:45: ijson Number: i64: 1, i64err: <nil>
        json_test.go:46: ijson Number: f64: 1.000000, f64err: <nil>
        json_test.go:34: case: {"a": 1.}
        json_test.go:38: ijson value: map[a:1.], error: <nil>
        json_test.go:39: ejson value: map[], error: invalid character '}' after decimal point in numeric literal
        json_test.go:45: ijson Number: i64: 0, i64err: strconv.ParseInt: parsing "1.": invalid syntax
        json_test.go:46: ijson Number: f64: 1.000000, f64err: <nil>
        json_test.go:34: case: {"a": 1.e1}
        json_test.go:38: ijson value: map[a:1.e1], error: <nil>
        json_test.go:39: ejson value: map[], error: invalid character 'e' after decimal point in numeric literal
        json_test.go:45: ijson Number: i64: 0, i64err: strconv.ParseInt: parsing "1.e1": invalid syntax
        json_test.go:46: ijson Number: f64: 10.000000, f64err: <nil>
        json_test.go:34: case: {"a": -.1}
        json_test.go:38: ijson value: map[a:-.1], error: <nil>
        json_test.go:39: ejson value: map[], error: invalid character '.' in numeric literal
        json_test.go:45: ijson Number: i64: 0, i64err: strconv.ParseInt: parsing "-.1": invalid syntax
        json_test.go:46: ijson Number: f64: -0.100000, f64err: <nil>
    --- PASS: TestJSONNumberDiffIE (0.00s)
    PASS
    ok      command-line-arguments  0.071s
    

    discussion

    Golang's encoding/json meets the JSON RFC 7159 standard. Its scanner's FSM will check the number literal's grammar first before parsing it by strconv.ParseInt / strconv.ParseFloat, so some number literals that accepted by strconv will be rejected by encoding/json at the first grammar checking pass. But jsoniter does't check it, instead it treats a string that made up of ['+', '-', '.', 'e', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] as a json.Number, so some number literals accepted by golang's strconv package but don't meet the JSON RFC 7159 standard will be wrongly accepted by jsoniter.

    Recently I try to replace jsoniter with my custom JSON library that modified from encoding/json to speed up our server, I write many unit-tests to ensure all cases that I could think of will have exactly the same decoding result as the encoding/json. But in our production environment I found some DIFF between jsoniter and my JSON library. The jsoniter's README said that it 100% compatibility with standard lib, but it's actually not. From the above test we can confirm that some strange number literals can be wrongly accepted by jsoniter, which will be rejected by encoding/json. This poses a risk to our JSON library migration because some special cases in our online requests which were fine before will cause errors after migration, and it's hard to prevent it to some extent as we don't know if there are any other DIFF between these two JSON libraries.

Fast JSON encoder/decoder compatible with encoding/json for Go
Fast JSON encoder/decoder compatible with encoding/json for Go

Fast JSON encoder/decoder compatible with encoding/json for Go

Sep 19, 2022
My clean Go solution that's faster than 100%, takes up less memory than 100%.

Remove-element My very clean Go solution that's faster than 100% of all solutions on Leetcode. Leetcode Challenge: "Given an integer array nums and an

Dec 24, 2021
go-eexcel implements encoding and decoding of XLSX like encoding/json

go-eexcel go-eexcel implements encoding and decoding of XLSX like encoding/json Usage func ExampleMarshal() { type st struct { Name string `eexce

Dec 9, 2021
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Description pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to

Sep 19, 2022
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Description pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to

Sep 19, 2022
Highly concurrent drop-in replacement for bufio.Writer

concurrent-writer Highly concurrent drop-in replacement for bufio.Writer. concurrent.Writer implements highly concurrent buffering for an io.Writer ob

Aug 14, 2022
Drop-in replacement for the standard library errors package and github.com/pkg/errors

Emperror: Errors Drop-in replacement for the standard library errors package and github.com/pkg/errors. This is a single, lightweight library merging

Sep 22, 2022
A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.
A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.

Errors Errors package is a drop-in replacement of the built-in Go errors package with no external dependencies. It lets you create errors of 11 differ

Aug 29, 2022
Zero downtime restarts for go servers (Drop in replacement for http.ListenAndServe)

endless Zero downtime restarts for golang HTTP and HTTPS servers. (for golang 1.3+) Inspiration & Credits Well... it's what you want right - no need t

Sep 22, 2022
a simple & tiny scrapy clustering solution, considered a drop-in replacement for scrapyd

scrapyr a very simple scrapy orchestrator engine that could be distributed among multiple machines to build a scrapy cluster, under-the-hood it uses r

Nov 24, 2021
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint

revive Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. Revive provides a framework for developme

Sep 19, 2022
drpc is a lightweight, drop-in replacement for gRPC
drpc is a lightweight, drop-in replacement for gRPC

drpc is a lightweight, drop-in replacement for gRPC

Sep 23, 2022
Drop-in replacement for Go net/http when running in AWS Lambda & API Gateway
Drop-in replacement for Go net/http when running in AWS Lambda & API Gateway

Package gateway provides a drop-in replacement for net/http's ListenAndServe for use in AWS Lambda & API Gateway, simply swap it out for gateway.Liste

Sep 24, 2022
Drop-in replacement for Go's stringer tool with support for bitflag sets.

stringer This program is a drop-in replacement for Go's commonly used stringer tool. In addition to generating String() string implementations for ind

Nov 26, 2021
twtr (pronounced "tweeter") is a drop-in replacement of the original twtxt client

twtr twtr (pronounced "tweeter") is a drop-in replacement of the original twtxt client, with some extensions and bonus features, so you can make the s

Jun 24, 2022
A drop-in replacement to any Writer type, which also calculates a hash using the provided hash type.

writehasher A drop-in replacement to any Writer type, which also calculates a hash using the provided hash type. Example package main import ( "fmt"

Jan 10, 2022
Goslmailer (GoSlurmMailer) is a drop-in replacement MailProg for slurm

GoSlurmMailer - drop in replacement for default slurm MailProg. Delivers slurm job messages to various destinations.

May 16, 2022
🔑A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout (LSM+WAL) similar to Riak.

bitcask A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout

Aug 24, 2022
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.

?? PTerm | Pretty Terminal Printer A golang module to print pretty text Show Demo Code PTerm.sh | Installation | Documentation | Quick Start | Example

Sep 20, 2022
the pluto is a gateway new time, high performance, high stable, high availability, easy to use

pluto the pluto is a gateway new time, high performance, high stable, high availability, easy to use Acknowledgments thanks nbio for providing low lev

Sep 19, 2021