I have the following nested dictionary my_dict
(which was originally JSON from a response to a request to an endpoint):
my_dict = {'SalesStatusResult': {'next_offset': -1,
'customers': [{'caCustomerID': 'N872-1665582527-adhoc-0:0',
'identifier': 'N872',
'customertype': '',
'blocked': False,
'location': 'London',
'expected_transaction_time': {'epoch': 1665582527,
'tz': 'EDT',
'dow': 'Wednesday',
'time': '09:48',
'date': '10/12/2022',
'localtime': 1665568127},
'estimated_order_time': {'epoch': 1665582527,
'tz': 'EDT',
'dow': 'Wednesday',
'time': '09:48',
'date': '10/12/2022',
'localtime': 1665568127},
'actual_order_time': {'epoch': 1665582527,
'tz': 'EDT',
'dow': 'Wednesday',
'time': '09:48',
'date': '10/12/2022',
'localtime': 1665568127},
'expected_settlement_time': {'epoch': 0,
'tz': '',
'dow': '',
'time': '',
'date': '',
'localtime': 0},
'status': 'Completed',
'status_code': 1,
'progress_percent': 100,
'state_code': 2,
'cust_id' : 'AD-17-C18'
}]}}
Notably, when calling type
on the object, it showed dict
, not JSON.
I would like to extract the value in the caCustomerID
key (which is "N872-1665582527-adhoc-0:0
").
Separately, I would also like to get the cust_id
, which is "AD-17-C18
".
How do I do this?
Thanks!