gpt4 book ai didi

json - Moshi 用不同的键解析 json

转载 作者:行者123 更新时间:2023-12-02 13:43:00 25 4
gpt4 key购买 nike

我正在寻找 PolymorphicAdapter但是我能找到的所有多态示例都有一个名为“type”的键或类似的东西,可以用来区分要使用的类。但是就我而言,我没有这样的 key 。我对如何解析这样一个奇特的 json 有点迷茫。

{
"infos": {
"1588318": {
"id": "1588318",
"id_user": "9701",
"profile_name": "Profile1",
"views": 100
},
"1588319": {
"id": "1588319",
"id_user": "7391",
"profile_name": "Profile2",
"views": 10
},
"1588320": false,
"1588321": {
"id": "1588321",
"deleted": true
}
}
}
data class UserInfo(val infos: Map<String, UserResult>)

sealed class UserResult {

data class UserDeleted(val id: String, val deleted: Boolean): UserResult()
data class UserInfoCard(
val id: String,
val title: String,
@Json(name = "profile_name") val profileName: String,
val views: Int
): UserResult()

}

最佳答案

最后我没有找到任何解决方案,在与 API 经理讨论后,他说他会更新一个 key 以确定它是否是 profiledeleted_profile

关于json - Moshi 用不同的键解析 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61769988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com