I have a JSON file that contains multiple objects
{
"Elements": [
{
"name": "Hydrogen",
"symbol": "H"
},
{
"name": "Lithium",
"symbol": "Li"
},
{
"name": "Sodium",
"symbol": "Na"
}
]
}
I want to be able to search them using the name but only a single one. So far, I've been able to read all of the elements together with an output like
Hydrogen
Lithium
Sodium
but I want to only read one of the objects not all of them. My python code for this so far is
import json
f = open('elements.json')
data = json.load(f)
for element in data['Elements']:
print(element['name'])