Я пытаюсь получить цепочку эволюции от PokeAPI, и мне помог другой ответ здесь в stackoverflow Как получить цепочку эволюции покемонов
Кстати, я непонимание того, как получить все элементы из «массива evolves_to» и затем вернуться на более высокий уровень, чтобы перейти к следующему элементу самого массива.Например, я хотел бы получить массив, подобный этому:
[{
"species_name": "charmander",
"min_level": 1,
"trigger_name": null,
"item": null
}, {
"species_name": "charmeleon",
"min_level": 16,
"trigger_name": "level-up",
"item": null
}, {
"species_name": "charizard",
"min_level": 36,
"trigger_name": "level-up",
"item": null
}]
, но из JSON, подобного этому, с массивами "evolves_to" с более чем одним элементом:
{
"baby_trigger_item": null,
"chain": {
"evolution_details": [],
"evolves_to": [
{
"evolution_details": [
{
"gender": null,
"held_item": null,
"item": null,
"known_move": null,
"known_move_type": null,
"location": null,
"min_affection": null,
"min_beauty": null,
"min_happiness": null,
"min_level": 7,
"needs_overworld_rain": false,
"party_species": null,
"party_type": null,
"relative_physical_stats": null,
"time_of_day": "",
"trade_species": null,
"trigger": {
"name": "level-up",
"url": "https://pokeapi.co/api/v2/evolution-trigger/1/"
},
"turn_upside_down": false
}
],
"evolves_to": [
{
"evolution_details": [
{
"gender": null,
"held_item": null,
"item": null,
"known_move": null,
"known_move_type": null,
"location": null,
"min_affection": null,
"min_beauty": null,
"min_happiness": null,
"min_level": 10,
"needs_overworld_rain": false,
"party_species": null,
"party_type": null,
"relative_physical_stats": null,
"time_of_day": "",
"trade_species": null,
"trigger": {
"name": "level-up",
"url": "https://pokeapi.co/api/v2/evolution-trigger/1/"
},
"turn_upside_down": false
}
],
"evolves_to": [],
"is_baby": false,
"species": {
"name": "beautifly",
"url": "https://pokeapi.co/api/v2/pokemon-species/267/"
}
},
{
"evolution_details": [
{
"gender": null,
"held_item": null,
"item": null,
"known_move": null,
"known_move_type": null,
"location": null,
"min_affection": null,
"min_beauty": null,
"min_happiness": null,
"min_level": 7,
"needs_overworld_rain": false,
"party_species": null,
"party_type": null,
"relative_physical_stats": null,
"time_of_day": "",
"trade_species": null,
"trigger": {
"name": "level-up",
"url": "https://pokeapi.co/api/v2/evolution-trigger/1/"
},
"turn_upside_down": false
}
],
"evolves_to": [
{
"evolution_details": [
{
"gender": null,
"held_item": null,
"item": null,
"known_move": null,
"known_move_type": null,
"location": null,
"min_affection": null,
"min_beauty": null,
"min_happiness": null,
"min_level": 10,
"needs_overworld_rain": false,
"party_species": null,
"party_type": null,
"relative_physical_stats": null,
"time_of_day": "",
"trade_species": null,
"trigger": {
"name": "level-up",
"url": "https://pokeapi.co/api/v2/evolution-trigger/1/"
},
"turn_upside_down": false
}
],
"evolves_to": [],
"is_baby": false,
"species": {
"name": "dustox",
"url": "https://pokeapi.co/api/v2/pokemon-species/269/"
}
}
],
"is_baby": false,
"species": {
"name": "cascoon",
"url": "https://pokeapi.co/api/v2/pokemon-species/268/"
}
}
],
"is_baby": false,
"species": {
"name": "silcoon",
"url": "https://pokeapi.co/api/v2/pokemon-species/266/"
}
}
],
"is_baby": false,
"species": {
"name": "wurmple",
"url": "https://pokeapi.co/api/v2/pokemon-species/265/"
}
},
"id": 135
}
Итак, как я могу сделать это плоским? Спасибо, кто ответит мне и извините за мой плохой английский.