The way this works is straightforward:
- For each JSON object determine whether it is a defined (bang bang!!) object.
- If it is an object, recursively call the function to traverse it.
- If it is not an object (example: array, string, value), then it must be a leaf node!
Take the Wikipedia API JSON tree as an example which looks like this:
The traverse function will iterate through each object, but for the sake of this example, scanning through the first object of the Pages object will look like this: