Trying to access an API that contains a specific tree structure:
{"19777621": [{
"queue": "RANKED_SOLO_5x5",
"name": "Vladimir's Maulers",
"entries": [{
"leaguePoints": 0,
"isFreshBlood": false,
"isHotStreak": true,
"division": "I",
"isInactive": false,
"isVeteran": false,
"losses": 34,
"playerOrTeamName": "Razdiel",
"playerOrTeamId": "19777621",
"wins": 36
}],
"tier": "PLATINUM"
}]}
Managed to work with several examples, but struggling with this particular one. The response body appears as undefined or blank when attempting any action.
<head>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="/js/json2.js"></script>
<script src="/js/json_parse.js"></script>
</head>
<body>
<script>
$.ajax({
url: 'https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/19777621/entry?api_key=b05c2777-462b-4bcc-ac2a-a3223bb74876',
type: 'GET',
dataType: 'json',
data: {
},
success: function (json) {
document.write("The Result Is:")
JSON_Encoded = json;
JSON_Decoded = JSON.stringify(json);
document.write(JSON_Decoded[19777621].name[0])
document.write(JSON_Decoded[19777621].entries.losses[0])
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("error getting Summoner data!");
}
});
</script>
An understanding that my approach is flawed and seeking guidance on how to correct it.