【发布时间】:2021-10-04 12:57:07
【问题描述】:
我有两个 api,一个向我发送一个 Appointment 对象,它的主体是这样的
data class Appointment(
id:Long = 4,
name:String = "name"
...
)
另一个人应该从我这里得到这个身体
{
name:"name"
}
没有 id 字段 在 kotlin 代码中,我想将 Id 设置为 null 并且 Gson 应该忽略它,因为它是 null 怎么做 ? 如何将 kotlin 类转换为没有空值的 json
【问题讨论】:
-
试试这个方法可能对你有帮助futurestud.io/tutorials/…
标签: android json gson retrofit2