提问人:Pawan Harariya 提问时间:10/20/2023 更新时间:10/20/2023 访问量:32
自定义适配器,用于根据 Retrofit 中使用 Moshi 的 JSON 响应中的参数过滤对象
Custom Adapter to filter objects based on a parameter from an JSON response in Retrofit using Moshi
问:
我收到如下 API 响应。数据字段是一个对象数组。我想根据字段将内容过滤到不同的列表中。Design
type
{
"code": 200,
"data": [
{
"id": "1",
"type": "typeA",
},
{
"id": "1",
"type": "typeB",
},
]
}
所以基本上我应该能够得到一个.这些类型是事先知道的。HashMap<DesignType, List<Design>()
这是我的数据类
@JsonClass(generateAdapter = true)
data class Design(
val id: String,
val type: DesignType
)
我已经浏览了一些帖子,但无法找到我需要的东西。这篇文章展示了如何提取列表,但我需要将内容过滤到不同的列表中。
答: 暂无答案
评论