I have JSON model,
{
"legends": {
"all": {
"Revenant": {
"ImgAssets": {
"icon": "https:\/\/api.mozambiquehe.re\/assets\/icons\/revenant.png",
"banner": "https:\/\/api.mozambiquehe.re\/assets\/banners\/revenant.jpg"
}
},
"Crypto": {
"ImgAssets": {
"icon": "https:\/\/api.mozambiquehe.re\/assets\/icons\/crypto.png",
"banner": "https:\/\/api.mozambiquehe.re\/assets\/banners\/crypto.jpg"
}
},
"Horizon": {
"data": [
{
"name": "Season 7 wins",
"value": 1,
"key": "wins_season_7",
"rank": {
"rankPos": 62637,
"topPercent": 69.39
},
"rankPlatformSpecific": {
"rankPos": 56257,
"topPercent": 68.58
}
},
{
"name": "Special event kills",
"value": 101,
"key": "specialEvent_kills",
"rank": {
"rankPos": 101058,
"topPercent": 65.11
},
"rankPlatformSpecific": {
"rankPos": 68184,
"topPercent": 61.62
}
},
{
"name": "Special event damage",
"value": 47004,
"key": "specialEvent_damage",
"rank": {
"rankPos": 96259,
"topPercent": 58.78
},
"rankPlatformSpecific": {
"rankPos": 66031,
"topPercent": 55.63
}
}
],
"ImgAssets": {
"icon": "https:\/\/api.mozambiquehe.re\/assets\/icons\/horizon.png",
"banner": "https:\/\/api.mozambiquehe.re\/assets\/banners\/horizon.jpg"
}
},
"Wraith": {
"data": [
{
"name": "Kills",
"value": 1356,
"key": "kills",
"rank": {
"rankPos": 162196,
"topPercent": 12.69
},
"rankPlatformSpecific": {
"rankPos": 121593,
"topPercent": 10.29
}
},
{
"name": "Season 7 kills",
"value": 233,
"key": "kills_season_7",
"rank": {
"rankPos": 17859,
"topPercent": 38.15
},
"rankPlatformSpecific": {
"rankPos": 15854,
"topPercent": 36.65
}
},
{
"name": "Season 7 wins",
"value": 13,
"key": "wins_season_7",
"rank": {
"rankPos": 11891,
"topPercent": 13.97
},
"rankPlatformSpecific": {
"rankPos": 10926,
"topPercent": 13.47
}
},
{
"name": "Special event kills",
"value": 1377,
"key": "specialEvent_kills",
"rank": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
},
"rankPlatformSpecific": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
}
},
{
"name": "Special event damage",
"value": 656195,
"key": "specialEvent_damage",
"rank": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
},
"rankPlatformSpecific": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
}
},
{
"name": "Special event wins",
"value": 68,
"key": "specialEvent_wins",
"rank": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
},
"rankPlatformSpecific": {
"rankPos": "NOT_CALCULATED_YET",
"topPercent": "NOT_CALCULATED_YET"
}
}
],
"ImgAssets": {
"icon": "https:\/\/api.mozambiquehe.re\/assets\/icons\/wraith.png",
"banner": "https:\/\/api.mozambiquehe.re\/assets\/banners\/wraith.jpg"
}
}
}
}
}
Then I make a data class:
data class TestHero (@SerializedName("global") val global: PlayerInf,
@SerializedName("legends")val legends: AllLegends)
data class PlayerInf (val name: String, val uid: Long, val avatar: String, val platform: String,
val level: Int, val toNextLevelPercent: Int, val internalUpdateCount: Int, val bans: BanInf, val rank: RankInf)
data class BanInf (val isActive: Boolean, val remainingSeconds: Int)
data class RankInf (val rankScore: Int, val rankName: String, val rankDiv: Int, val rankImg: String)
data class AllLegends (@SerializedName("all") val all : Revenant, @SerializedName("all")val all2: Horizon)
data class Revenant (val ImgAssets: String)
data class Horizon (val data : ArrayList<Rang0>, val ImgAssets: String)
class Legends(){
data class Revenant (val ImgAssets: String)
data class Horizon (val data : ArrayList<Rang0>, val ImgAssets: String)
}
data class Rang (val t0 : Rang0)
data class Rang0 (val name: String, val value: Int, val key: String)
But I get the error:
Unable to create converter for class
Having looked for answers to stackoverflow, I realized that you can not double serialize a class object. But how do you get the data then?
I tried to do it separately, but it turned out to get the data of only 1 object
example:
data class AllLegends (@SerializedName("all") val all : Revenant)
help me figure it out please