I have a json hash which has a lot of keys. I retrieve this hash from a web service at regular intervals and for different parameters etc. This has more or less fixed structure, in the sense that keys are sometimes missing. So I end up with a lot of code of the following nature
Edit:
Sample data
data =
{
id1 : {dict...},
id2 : {dict..},
'' : {value...},
...
}
for item in data:
id = data.get("id")
if not id:
continue
...
I want to skip the 3rd element and move on. The structure data
is a nested dict
and I loop inside each of these nests. There are keys missing there as well :(
I was wondering if there was a more elegant solution than having 50 different if
s and continue
s
Thanks