How can if check is some fields exist in a json object ?
v = {
"f1":"v1",
"f2":"v2",
"f3":"v3",
"f4":"v4",
"f5":"v5"
}
I have this code:
if v['f1']:
print "f1 exists"
elif v['f2']:
print "f2 exists"
elif v['f3']:
print "f3 exists"
But sometime, when a field doen't existe, exception is fired and the other test fail. How can I do this test ?