I am trying in a loop that I will create later to give out the names(single) for an Api Post request (here for testing as print) and Change the Vaule oft the Variable in each turn of the loop. Now im running in Exception:KeyError 0.
My question is. Is there an Variable that i can use for [0] (Key_name)
Can someone help there?
file.json:
(Shortened, the real file is much longer)
{ "_meta": {
"Example1": {
"00000001": {
"name": "Test-01",
},
"00000002": {
"name": "Test-02"
},
},
}
import json
data = json.load(open("file.json"))
name = data["_meta"]["Example1"][0]["name"]
print(f"Name: {name}")
Exception: KeyError 0
Edit
"Example1": {
"00000001": {
"name": "Test-01",
},
"00000002": {
"name": "Test-02"
"uuid": "Test-uuid"
"config": {
"ipAdresse": "Test-Ip"
},
},
},
}