jsonparser
jsonparser copied to clipboard
Array strings
Description:
In master, EachKey cannot extract from an array of strings. Specifying foo.[0]
would return nothing for {"foo": ["a","b"]}
, because EachKey calls the Get function twice and in the case of strings inside arrays, the first Get strips quotes and the second then cannot recognize that it has been passed a string.
This PR appears to make extraction from arrays of strings work properly without breaking any existing tests. It includes a test which failed on master but passes with the changes.
Benchmark before change: Neither benchmark worked:
$ go test -test.benchmem -bench JsonParser ./benchmark/ -benchtime 5s -v
go: directory benchmark is outside main module
$ 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
Unable to find image 'jsonparser:latest' locally
docker: Error response from daemon: pull access denied for jsonparser, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
make: *** [Makefile:16: bench] Error 125
PTAL
PTAL.
Hello, Is there anything I can do to help get this PR merged?
PTAL
any update here?
I am using a fork with the above patch, would love to remove a replace directive from my go.mod if possible. The code looks solid and I have tested it a ton.
Do we know why this is left open? Seems that it would be a fix for this: https://github.com/grafana/loki/issues/9179
@buger Hello, can you have a look at this fix? Thanks in advance
Hello, any news?