A tool for iterating dictionaries as trees and printing all leaf nodes at some path
Takes a dict, and a path delimited with slashes like A/B/C/D, and returns a list of all leaves at all trajectories dict[A][B][C][D]
If the path is an empty string, returns the original dict
Each non-leaf node can be either a dictionary or list of objects including dictionaries.
Each leaf node can be an arbitrary object.
Non-leaf inner nodes that are not dictionaries are ignored.
Jsons sometimes have many levels and are a pain to parse.
- This package was motivated by the pain in iterating dicts I received from calling simplejson on objects returned from various Twitter API calls. The API objects I had to parse had quadruple level nested dictionaries, and when I was playing around with the data, I wanted to be able to query different levels to see if the data was interesting.
- Then I found out nothing in the Python language natively supports querying nested dicts when they may or may not exist: http://stackoverflow.com/questions/26979046/python-check-multi-level-dict-key-existence