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

Does not support struct tags #52

Open
skyzyx opened this issue Apr 1, 2020 · 1 comment
Open

Does not support struct tags #52

skyzyx opened this issue Apr 1, 2020 · 1 comment

Comments

@skyzyx
Copy link

skyzyx commented Apr 1, 2020

I have a series of structs to represent my JSON, which I use instead of a generic interface{}. My structs have json: tags, but JMESPath appears to ignore them.

@primexiao
Copy link

As I see the doc in README.md, maybe var data interface{} could be the best practice, we should have our own function like this:

func jmespathSearch(pattern string, jsonBytes []byte) (interface{}, error) {
    // use the simple type: interface{}
    var data interface{}
    json.Unmarshal(jsonBytes, &data)
    return jmespath.Search(pattern, data)
}

Hope it helps.

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