Currently, I am iterating through an array of waypoints fetched from the Google Maps API. Within this array, I need to retrieve the values labeled Xa and Ya. Right now, I'm accessing these values using [i]["location"]["Xa"]
, but the labels can vary (e.g., aB and aC, Ya and Za). Is there a universal method to fetch these values?
[
{
"location":{
"Xa":xx.xxxxxxxxxxxxx,
"Ya":xx.xxxxxxxxxxxxx
},
"stopover":true
},
{
"location":{
"Xa":xx.xxxxxxxxxxxxx,
"Ya":xx.xxxxxxxxxxxxx
},
"stopover":true
},
{
"location":{
"Xa":xx.xxxxxxxxxxxxx,
"Ya":xx.xxxxxxxxxxxxx
},
"stopover":true
},
{
"location":{
"Xa":xx.xxxxxxxxxxxxx,
"Ya":xx.xxxxxxxxxxxxx
},
"stopover":true
}
]