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

call Find() twice with the same path but got nil for the second time #103

Open
Boyy-Next-Door opened this issue Mar 2, 2023 · 2 comments

Comments

@Boyy-Next-Door
Copy link

        jq := gojsonq.New().FromString(string(data))
	path1 := fmt.Sprintf("data.dynamicConfig.%s.feConfig.areaLevel", req["corpId"].(string))
	areaLevel := jq.Find(path1)     // got correct value    interface{} | float64 => 3
	areaLevel2 := jq.Find(path1)   // got interface{}  => nil

Is there anything wrong in this use case ? 😭

@Boyy-Next-Door
Copy link
Author

oh! I realized that I need to call Reset() before Find() again!

	areaLevel := jq.Find(fmt.Sprintf("data.dynamicConfig.%s.feConfig.areaLevel", req["corpId"].(string)))
	areaRange := jq.Reset().Find(fmt.Sprintf("data.dynamicConfig.%s.feConfig.areaRange", req["corpId"].(string)))

@kshji
Copy link

kshji commented Jun 8, 2023

I done also lot of ... before found this info. And saw Reset() wiki.
I hope you add to the basic examples:
a) make more than one query to the source - after readed json file
b) how to use query after query without reset

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