Let's dive right in. I am receiving a JSON object that contains another object within it, like this:
function getSummonerInfo(summonerName, region) {
LolApi.Summoner.getByName(summonerName, region, function(err, summoner) {
if(!err) {
console.log(summoner);
}
});
}
After making the call, the result looks something like this (assuming summonerName is "tetsii"):
{ tetsii:
{ id: 51520537,
name: 'tetsii',
profileIconId: 23,
summonerLevel: 23,
revisionDate: 1408307600000
}
}
While I can access the ID using "console.log(summoner.tetsii.id)" for example, I prefer not to hardcode the name "tetsii" as the data could vary. So my question is: how can I access the inner object in a JSON or is there a better way? Unfortunately, an array is not an option in this scenario as far as I know.
I tried "console.log(summoner.summonerName.id)", but since summonerName is a string, that approach did not work.
Thank you to everyone who contributed!
-Tetsii