Reputation: 131
I have a tuple r[0] which is of this format:
(OrderedDict([('attributes', OrderedDict([('type', 'CCE__c'), ('url', 'aA1')])), ('VARIABLE1', '00AE'), ('Opportunity__r', OrderedDict([('attributes', OrderedDict([('type', 'Opportunity'), ('url', 'NyzIAE')])), ('VARIABLE2', 'uJeIAK')])), ('VARIABLE3', 'a05EA1'))
I'm trying to extract VARIABLE1 and VARIABLE2. When I use:
r[0]['VARIABLE1']
I'm able to extract correctly. However, when I use:
r[0]['VARIABLE2']
it's throwing an error. Could someone tell me how to correctly extract Variable 2?
Upvotes: 0
Views: 577
Reputation: 109
you have a small structural problem, to access the VARIABLE2
key, you must first access theOpportunity__r
key.
Use the method of your variable items()
, to see all keys:
r = (OrderedDict([('attributes', OrderedDict([('type', 'CCE__c'), ('url', 'aA1')])), ('VARIABLE1', '00AE'), ('Opportunity__r', OrderedDict([('attributes', OrderedDict([('type', 'Opportunity'), ('url', 'NyzIAE')])), ('VARIABLE2', 'uJeIAK')])), ('VARIABLE3', 'a05EA1')]), )
r[0].keys()
r[0]['Opportunity__r']['VARIABLE2']
Upvotes: 1