I'm reading strings from a file that are in JSON format, all of which could be slightly different. Specifically the following examples:
No List Example
[{"pricing-model":{"qualifier":{"and":{"all":{"equals":{"constant":...
List Example
{"pricing-model":{"qualifier":{"or":{"and":[{"all":{"equals":{"constant":...
If the string contains a list, I need to process it differently than if does not have a list.
Example Code
with open('my.jason') as f:
data = json.load(f)
for item in data:
item = [item]
# Get dictionary items
item.get('pricing-model',{}).get('qualifier',{}).get('and',{}).get('all',{})\
.get('equals',{}).get('constant',{})
# Get list items
item.get('pricing-model',{}).get('qualifier',{}).get('and',[])
But how do I validate if the sting contains a list so I can run the correct .get?