This following datastructure is in JSON. I want to know how I can write an if
statement to check if there are any objects inside the key causes_virtual
. I have tried using both if len(api_response_article[0]['causes_virtual']) == 0:
or if not api_response_article[0]['causes_virtual']:
, however neither of these works. Could this be because there are dictionaries inside of a list
{
"additional_info": "",
"approved_at": null,
"approved_by_id": null,
"causes_virtual": [ # THIS SECTION
{
"id": 5408600,
"models": [
"Potatoes"
],
"principals": "Some irrelevant text",
"title": "We farm potatoes or something"
}
],
"created_at": "2021-03-03T01:13:04.477348+00:00",
"created_by_id": 1019500
}
Any pointers would be helpful. Thanks in advanced!
Aucun commentaire:
Enregistrer un commentaire