Reputation: 93
I am working with a minimally documented API. The response returns an object and, within that object, I have data I need...
i.e.
response: {
locations: {
location: {
21421: { <-- this is random
...data needed in here
}
}
}
}
The 21421
property appears to be a random number. I have no idea why, again, the documentation is very sparse. Is there any way to get the immediate child property of the response.locations.location
? If so, that would greatly help me.
Thanks!
Upvotes: 1
Views: 75
Reputation: 78550
You can iterate over it using for...in
for(var prop in response.locations.location) {
console.log(response.locations.location[prop])
}
Upvotes: 1