Recently, I've been struggling with referencing a variable in JSON dot notation within my meteor application. It seems that when trying to access respJson.userlower.name, userlower is not being recognized as a valid variable. Is there a workaround for this issue? The reason why I need userlower to be a variable is because it's passed into the function and contains the username. The JSON data I'm receiving looks like this:
{"tiandi":{"id":19888066,"name":"Tiandi","profileIconId":7,"summonerLevel":30,"revisionDate":1416925919000}}
try {
var result = HTTP.get(url, function(err, result){
console.log(result);
if (result.statusCode == 200) {
var userlower = userName.toLowerCase();
var respJson = JSON.parse(result.content);
console.log("response received.");
GameList.insert({
IGN: respJson.userlower.name,
level: respJson.userlower.summonerlevel,
Game: "League of Legends"
});
}
});
} catch (e) {
console.log(e);
}