Open tomelm opened 4 years ago
Yes, it's expected. Query it's like a chain if you move forward you can't automatically return back to previous state. There is Reset/0 method. Although it would be great to have opportunity save current state and return not only to start point.
I appreciate the thought, it would be great if the reset calls invoke automatically. This can be an improvement.
Thanks @Kvaz1r, that's what I was looking for! Maybe for Find
it automatically resets since it seems like users won't really be building queries with that?
Yeah, an efficient reset would be nice here for uses cases where we want to initialize the query object given a map and then just query for specific values given their paths many times.
Also https://github.com/thedevsaddam/gojsonq/wiki/Queries#findpath mentions that
Caveat: You can't chain further query methods after it. If you need that, you should use From() method
so it's be compatible with the design.
I'm trying to use gojsonq to make some queries to JSON data. I was setting up some tests that were returning
nil
when I tried to validate the data inside of the JSON object. Eventually, I noticed if I do multipleFind
s, it starts returningnil
.Here's an example of the behavior: https://play.golang.org/p/qxiooDmflIe
Is this expected? I couldn't find a way in the documentation to run the same query multiple times and get the same data back.