I have created JSON file like this and I want to access email this is the JSON file
{
"customers": {
"OscarLang": {
"email": "gmail@gmail.com",
"events": []
},
"foretz-abdo": {
"email": "hotmail@hotmail.com",
"events": []
},
"testuser": {
"email": "test@hotmail.com",
"events": []
},
"AAS": {
"email": "osdaadawdaw@asdad.com",
"events": []
}
}
}
and this what I tried
sources = ["customers.json"]
for source in sources:
data = util.get_data_item(source)
if data is None or len(data) == 0:
continue
register = json.loads(data)
for json_obj in register['customers']:
print(json_obj)
try:
emailaddress = json_obj['email']
except Exception as e:
emailaddress = None
print(emailaddress)
when I print emailaddress I get NONE