is there a better way to parse data structures that can consist of multiple types (strings/int/list/dict) without checking every entry for its type or some syntax trick to get the job done?
if 'enclosure' in item and isinstance(item['enclosure'], dict):
if item['enclosure'].get('attributes') and isinstance(item['enclosure']['attributes'], dict) and item['enclosure']['attributes'].get('length'):
size = int(item['enclosure']['attributes']['length'])
The main problem is to get all the chained checks, since otherwise
.get() will result in errors if its a string. Any tips how to handle this for a deep data structure? In my case i need parse a json object that has no well defined structure.