I'm trying to get the values of the first object's direction
and station
returned in this JSON, but I'm getting the following error
KeyError: 0
Here's my code:
print(json.dumps(savedrequest, indent=4))
savedstation = savedrequest[0]['station']
saveddirection = savedrequest[0]['direction']
And this is what it's returning in the print:
{
"-bas": {
"email_address": "dd3@gmail.com",
"direction": "Southbound",
"station": "place-har"
},
"-bus": {
"email_address": "dd4@gmail.com",
"direction": "Southbound",
"station": "place-su"
}
}
I don't know what -bas
or -bus
is going to be when it gets returned, I need to select the first object in the array.