Is it possible to get a new JsonPath object out of a current one? The only thing I've found is setRootPath()
but that's not exactly what I'm looking for since you cannot "go back" once you've set the root.
My use case:
I have a JSON array of objects. I'd like to go over the JSON array and pass each object to some function. The thing is, I don't want to deserialize the object nor to pass a LinkedHashMap. Instead, I'd like to pass a JsonPath that represents the object alone.
Additional Info:
Let's assume we have the following JSON:
[
{"name": "David"},{"name": "Dana"},{"name": "Ron"}
]
And we've just read it using JsonPath:
JsonPath = JsonPath.from(json);
I'd like to iterate over the objects and for each object have a JsonPath
that represents it. The only way to do it (as far as I can tell) is to use setRootPath()
but once you do that you can't go back.