call Find() twice with the same path but got nil for the second time
Boyy-Next-Door opened this issue · 2 comments
Boyy-Next-Door commented
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 commented
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 commented
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