The variable data has the following JSON
{
"destination_addresses" : [ "Stade Leopold Sedar Senghor, Route de Yoff, Dakar, Senegal" ],
"origin_addresses" : [ "Unnamed Road, Dakar, Senegal" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "13.0 km",
"value" : 13007
},
"duration" : {
"text" : "23 mins",
"value" : 1383
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
I then run the following code:
parsed = json.loads(data)
I want to store distance "text" and "value", and duration "text" and "value" and "status" into variables in python. I tried the following code but it did not work:
dist = int(parsed['rows']['elements']['distance']['value'])
But I am getting an error
[]arelists,{}aredicts.TypeError: list indices must be integers, not str