Python code:
import json
aaa='''
{
"eee":"yes",
"something": null,
"ok": ["no","mmm","eee"],
"please":false,
"no": {"f":true,"h":"ttt"}
}
'''
data=json.loads(aaa)
When I do:
print(len(data))
I get as expected:
5
and
print(len(data['ok']))
which gives
3
But somehow
print(data[0])
gives
Traceback (most recent call last):
File "file.py", line 34, in <module>
print(data[0])
KeyError: 0
How do I get a term inside this JSON object using its index?
KeyErroris because you do not have0as key in yourdictionary