Good evening!
I'm having a problem finding brackets case by case.
I'm trying to get the data from "stats" . But the only reference you have is "accountId" or "summonerName" . To get a reference to "stats" you need to get the "participantId" id that is inside "participantIdentities"
But my problem is that I can not get the id "participantId" .
JSON Base - Example
{
"gameId":1189987226,
"participantIdentities":[
{
"player":{
"summonerName":"Khal Droggo",
"accountId":1595535
},
"participantId":1
},
{
"player":{
"summonerName":"Lefetos",
"accountId":211703728
},
"participantId":2
}
],
"participants":[
{
"stats":{
"champLevel":16,
"participantId":1
},
"participantId":1
},
{
"stats":{
"champLevel":15,
"participantId":2
},
"participantId":2
}
]
}
I'm using javascript language.
function callback(andress, fn){
$.ajax({
url: andress,
type: 'GET',
dataType: 'json',
error: function(){},
success: fn
});
}
function stats(accountId){
callback('https://api.myjson.com/bins/1ew27p', function(retorno) {
var obj = retorno.participantIdentities;
Object.keys(obj).forEach(function(prop) {
if (obj[prop].accountId == accountId) {
document.write(obj[prop].participantId);
}
});
});
}
stats(211703728);