I've loaded a JSON file but I'm not able to parse it in order to update or insert values.
The JSON structure is similar to this one:
{
"nodes": [
{
"id": "node1",
"x": 21.0,
"y": 8.0
},
{
"id": "node5",
"x": 3.0,
"y": 5.0
}
]
}
While my python code to retrieve a node is similar to this:
jsonData = defaultdict(list)
with open('data.json', 'r') as f:
jsonData = json.load(f)
print jsonData['nodes']['id'] == 'node5'
The error I get is "TypeError: list indices must be integers, not str".
How can I retrieve a node and how can I update it?
,after the}which shouldn't be there.