jsonparser
jsonparser copied to clipboard
Leading whitespaces lead to incorrect results (jsonparser.ArrayEach)
data := []byte(`[1, 2, 3]`)
jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) {
fmt.Println(string(value))
})
returns
1 2 3
but
data := []byte(` [1, 2, 3]`)
jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) {
fmt.Println(string(value))
})
returns
[1, 2, 3]
Similarly, Delete seems to "silently" fail when there is leading whitespace: This works: https://play.golang.org/p/Jub6y91ObT0 This doesn't: https://play.golang.org/p/FLM_k3GU6nc
Should be a pretty simple fix, e.g. just skip spaces at the start. PRs are welcomed :)
Fixed now, thanks @daria-kay!
Have to re-open because of bug found by OSS-Fuzz. See attached PR for error details.
OSS-Fuzz bug is solved by #227. Can issue be closed?