Find RapidJSON value's parent

332 Views Asked by At

Given a Value in a RapidJSON document, is it possible to easily find that Value's parent?

Specifically, we're using Pointer to find a value, but we then want to move back up one level to find that value's parent.

I was hoping there would be an easily available GetParent() or even a Pointer statement that would move me up one level, but so far I haven't found it.

All I've come up with is to then iterate through the entire tree, checking child items until I find it. I haven't tried to do that yet, but presumably it's possible (but wildly inefficient).

Help?

1

There are 1 best solutions below

1
On

Turns out this is dead simple and I'd missed it in reading the JSON Pointer docs. To move up one level from a particular point:

1

So to move up one level and then descend into a branch named "Foods":

1/Foods

To move up two levels and then descend into a branch named "Simple":

2/Simple