I am trying to print only project name from data which looks like this
[{'Project Name': 'ABC'}, {'Customer Name': None}, {'Customer Address': None}, {'Project Description': 'Industries Pvt limited'}]
with my Python Code
with open('project.json', 'r') as f:
data = json.load(f)
print(data)
for p in data:
if 'Project Name' in p:
print(p)
#Here it prints {'Project Name': 'ABC'}
# Print each property of the object
for p in data:
print(p['Project Name'])
It prints out the Project Name as ABC but gives a Key Error like this
KeyError: 'Project Name'