I have a question about JSON.
I need to pull the information inside the array. But I do not have the reference that would be the name of champion that is inside the date I need to find, the only thing you have is the key .
JSON Base:
{
"type":"champion",
"format":"standAloneComplex",
"version":"7.18.1",
"data":{
"Aatrox":{
"id":"Aatrox",
"key":"266",
"name":"Aatrox",
"title":"a Espada Darkin",
"image":{
"full":"Aatrox.png",
"sprite":"champion0.png",
"group":"champion",
"x":0,
"y":0,
"w":48,
"h":48
}
},
"Viktor":{
"id":"Viktor",
"key":"112",
"name":"Viktor",
"title":"o Arauto das Máquinas",
"image":{
"full":"Viktor.png",
"sprite":"champion4.png",
"group":"champion",
"x":0,
"y":0,
"w":48,
"h":48
}
}
}
}
I'm using javascript language with jquery. Pulling the data does not locate. How do I resolve this?
$.ajax({
type:'GET',
url: 'http://ddragon.leagueoflegends.com/cdn/7.18.1/data/pt_BR/champion.json',
dataType:'json',
success: function(data) {
var arr = [];
arr.push(data);
for(var i=0; i<arr.length; i++) {
if(arr[i].data.key === 266) {
console.log(arr[i].data.name);
}
}
},
error: function(data) { }
});