jsonparser icon indicating copy to clipboard operation
jsonparser copied to clipboard

Array strings

Open floren opened this issue 4 years ago • 8 comments

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

floren avatar Oct 25 '19 22:10 floren

PTAL

floren avatar Aug 07 '20 14:08 floren

PTAL.

floren avatar Jul 27 '21 19:07 floren

Hello, Is there anything I can do to help get this PR merged?

cedecegreen avatar May 24 '22 07:05 cedecegreen

PTAL

john-floren-gravwell avatar Dec 12 '22 18:12 john-floren-gravwell

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.

kris-watts-gravwell avatar Jan 11 '23 00:01 kris-watts-gravwell

Do we know why this is left open? Seems that it would be a fix for this: https://github.com/grafana/loki/issues/9179

slvlirnoff avatar Sep 22 '23 20:09 slvlirnoff

@buger Hello, can you have a look at this fix? Thanks in advance

MichelHollands avatar Oct 11 '23 08:10 MichelHollands

Hello, any news?

jrgvf avatar Jan 25 '24 20:01 jrgvf