Ниже приведен вывод JSON из API, у меня возникли проблемы при попытке сравнить переменные "last_save", и если профиль имеет большее значение "last_save", установите "profile_id" в качестве переменной. (Я довольно новичок в скрипте java, извините, если я использую неверную терминологию)
Вот код:
function profileID(){
console.log("Running profileID.")
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
rawJsonText = this.responseText;
var parsedText = JSON.parse(rawJsonText);
console.log(parsedText)
console.log(playerUUID)
lastPlayedIslandID = parsedText[0].last_save
lastPlayedProfileName = parsedText.profile_id
console.log(nameMC+"'s island ID : "+lastPlayedIslandID);
console.log(nameMC+"'s island name : "+lastPlayedProfileName);
slayerZombie();
}
};
xhttp.open("GET", slothpixelAPI+"skyblock/profiles/"+nameMC, true);
xhttp.send();
}
Это вывод JSON из API:
{
"5ab88f71d10747aabf643e666c9933b1": {
"profile_id": "5ab88f71d10747aabf643e666c9933b1",
"cute_name": "Grapes",
"first_join": 1578113432038,
"last_save": 1582337480211,
"collections_unlocked": 0,
"members": [
"4878f8a455e84956b19d4873d837ab93"
]
},
"4878f8a455e84956b19d4873d837ab93": {
"profile_id": "4878f8a455e84956b19d4873d837ab93",
"cute_name": "Coconut",
"first_join": 1560932868602,
"last_save": 1583315330184,
"collections_unlocked": 59,
"members": [
"8d32864b3a364035922dd84d5247f483",
"4878f8a455e84956b19d4873d837ab93"
]
}
}
Спасибо