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 jmespath support maps? #96

Open
luanhdeandrade opened this issue Nov 18, 2024 · 0 comments
Open

Does jmespath support maps? #96

luanhdeandrade opened this issue Nov 18, 2024 · 0 comments

Comments

@luanhdeandrade
Copy link

Hello all,
I have this code snippet:

fmt.Printf("Hardcoded path value: %v\n", data.Deployments["watchdog"].LivenessProbe.Port)
result, err = jmespath.Search(`"deployments"`, *data)
fmt.Printf("Result 1: %#v err: %v\n", result, err)
result, err = jmespath.Search(`"deployments"."watchdog"`, *data)
fmt.Printf("Result 2: %#v err: %v\n", result, err)

The results are:

Hardcoded path value: 40385
Result 1: map[string]*onechart.Deployment{"watchdog":(*onechart.Deployment)(0xc0004e5040)} err: <nil>
Result 2: <nil> err: <nil>

It seems like jmespath is fully able to traverse a struct and get a Field in there, but fails to grab it when this is a map key.

Is this expected? Are there any alternatives?
Regards.

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

1 participant