Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path/Search does not work with arrays #127

Closed
squillace91 opened this issue Oct 17, 2022 · 2 comments
Closed

Path/Search does not work with arrays #127

squillace91 opened this issue Oct 17, 2022 · 2 comments

Comments

@squillace91
Copy link

The example given in the readme also does work. This is what I get when trying to run the example.

image

@mihaitodor
Copy link
Contributor

Are you using github.com/Jeffail/gabs/v2? It seems to work fine for me:

package main

import (
	"github.com/Jeffail/gabs/v2"
)

func main() {
	jsonParsed, err := gabs.ParseJSON([]byte(`{"array":[{"value":1},{"value":2},{"value":3}]}`))
	if err != nil {
		panic(err)
	}
	val := jsonParsed.Path("array.1.value").String()
	if val != "2" {
		panic(val)
	}
}

@squillace91
Copy link
Author

Hey @mihaitodor,

You are right, on v2 that does work. I apologize. I already had the library installed so didn't see the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants