jsonparser
jsonparser copied to clipboard
Change ArrayEach CB Signature to Return Error
Description: Changes the callback function signature of ArrayEach to return an error. It currently takes an error as input even though ArrayEach never passes a non-nil error into it. It should be more like ObjectEach which returns an error from its callback function.
I had to fix Dockerfile and benchmark/benchmark_codecgen.go in order to get benchmarks to run.
(...it makes this repository seem very under-maintained).
Benchmark before change: DID NOT WORK
Benchmark after change:
$ make bench
docker run -v `pwd`:/go/src/github.com/buger/jsonparser -i -t jsonparser go test -test.benchmem -bench JsonParser ./benchmark/ -benchtime 5s -v
goos: linux
goarch: amd64
pkg: github.com/buger/jsonparser/benchmark
BenchmarkJsonParserLarge-4 100000 65332 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserMedium-4 1000000 9871 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserDeleteMedium-4 1000000 10448 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualMedium-4 1000000 6816 ns/op 112 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructMedium-4 1000000 7636 ns/op 672 B/op 12 allocs/op
BenchmarkJsonParserObjectEachStructMedium-4 1000000 10229 ns/op 624 B/op 11 allocs/op
BenchmarkJsonParserSmall-4 10000000 1081 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualSmall-4 10000000 810 ns/op 80 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructSmall-4 10000000 935 ns/op 144 B/op 4 allocs/op
BenchmarkJsonParserObjectEachStructSmall-4 10000000 815 ns/op 128 B/op 3 allocs/op
BenchmarkJsonParserSetSmall-4 5000000 1593 ns/op 816 B/op 5 allocs/op
BenchmarkJsonParserDelSmall-4 5000000 1889 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/buger/jsonparser/benchmark 113.794s
@buger : I was in the process of writing the exact same pull request when I noticed this was already there... Any chance to have this merged ?