У меня есть данные из API, выглядящие так:
{
"id": 2015,
"area": {
"id": 2081,
"name": "France"
},
"name": "Ligue 1",
"code": "FL1",
"emblemUrl": null,
"plan": "TIER_ONE",
"currentSeason": {
"id": 499,
"startDate": "2019-08-09",
"endDate": "2020-05-31",
"currentMatchday": 21,
"winner": null
},
"seasons": [
{
"id": 499,
"startDate": "2019-08-09",
"endDate": "2020-05-31",
"currentMatchday": 21,
"winner": null
},
{
"id": 177,
"startDate": "2018-08-10",
"endDate": "2019-05-25",
"currentMatchday": 38,
"winner": null
},
{
"id": 17,
"startDate": "2017-08-04",
"endDate": "2018-05-27",
"currentMatchday": 38,
"winner": {
"id": 524,
"name": "Paris Saint-Germain FC",
"shortName": "PSG",
"tla": "PSG",
"crestUrl": "https://upload.wikimedia.org/wikipedia/en/a/a7/Paris_Saint-Germain_F.C..svg"
}
},
{
"id": 333,
"startDate": "2016-08-12",
"endDate": "2017-05-20",
"currentMatchday": null,
"winner": null
},
{
"id": 334,
"startDate": "2015-08-07",
"endDate": "2016-05-14",
"currentMatchday": null,
"winner": null
},
{
"id": 335,
"startDate": "2014-08-08",
"endDate": "2015-05-23",
"currentMatchday": null,
"winner": null
},
{
"id": 336,
"startDate": "2013-08-09",
"endDate": "2014-05-17",
"currentMatchday": null,
"winner": null
},
{
"id": 337,
"startDate": "2012-08-10",
"endDate": "2013-05-26",
"currentMatchday": null,
"winner": null
},
{
"id": 338,
"startDate": "2011-08-06",
"endDate": "2012-05-20",
"currentMatchday": null,
"winner": null
}
],
"lastUpdated": "2020-01-25T13:55:00Z"
}
И я пытаюсь получить их в kotlin, но я не знаю, как получить массив 'seasons' , Вот мой kotlin класс с моделью данных
data class CompetitionModel(
@SerializedName("id")
val id: String?,
@SerializedName("area")
val area: AreaModel?,
@SerializedName("name")
val name: String?,
@SerializedName("code")
val code: String?,
@SerializedName("emblemUrl")
val emblemUrl: String?,
@SerializedName("plan")
val plan: String?,
@SerializedName("currentSeason")
val currentSeason: CurrentSeasonModel?,
@SerializedName("seasons")
val seasons: CurrentSeasonModel,
@SerializedName("lastUpdated")
val lastUpdated: String?
data class AreaModel(
@SerializedName("id")
val id: String = "",
@SerializedName("name")
val name: String = ""
data class CurrentSeasonModel(
@SerializedName("id")
val id: String = "",
@SerializedName("startDate")
val startDate: String = "",
@SerializedName("endDate")
val endDate: String = "",
@SerializedName("currentMatchday")
val currentMatchday: String = "",
@SerializedName("winner")
val winner: String = ""
class SeasonModel(
var seasons: CurrentSeasonModel
Поскольку моя SeasonModel (когда я пытаюсь добавить []) выдает ошибку: «Параметры должны иметь аннотацию типа» - но у меня есть CurrentSeasonModel как мой тип - что я делаю не так?