I have downloaded some data that returns a dictionary, I've provided a sample below. I thought it might be a nested dictionary, but it doesn't really look like one. (I'm new to python)
I don't understand the structure of this dictionary and how to extract data from it.
I want to extract the values for given keys. So to start with, return value where key = 'id'
Here is the sample dictionary and one type of code that I've tried to use:
my_dict = {'id': 5729283,
'title': 'Auto & Transport(L1)',
'colour': None,
'is_transfer': None,
'is_bill': None,
'refund_behaviour': None,
'children': [{'id': 5698724,
'title': 'Car Insurance',
'colour': None,
'is_transfer': False,
'is_bill': True,
'refund_behaviour': 'credits_are_refunds',
'children': [],
'parent_id': 5729283,
'roll_up': False,
'created_at': '2019-07-25T12:38:46Z',
'updated_at': '2021-01-19T08:12:28Z'},
{'id': 5729295,
'title': 'Toll',
'colour': None,
'is_transfer': False,
'is_bill': False,
'refund_behaviour': None,
'children': [],
'parent_id': 5729283,
'roll_up': False,
'created_at': '2019-08-05T04:30:55Z',
'updated_at': '2021-01-08T02:33:11Z'}],
'parent_id': None,
'roll_up': True,
'created_at': '2019-08-05T04:28:04Z',
'updated_at': '2021-01-08T02:44:09Z'}
temp = 'id'
[val[temp] for key, val in my_dict.items() if temp in val]
[val[temp] for key, val in my_dict.items() if temp in val]