[英]How to serialize a data class in Android Kotlin using moshi
@JsonClass(generateAdapter = true)
data class Note(val name)
Do I need to parcelize the above model I am using Moshi and change it to something like我是否需要打包上面的 model 我正在使用 Moshi 并将其更改为类似
@Parcelize
@JsonClass(generateAdapter = true)
data class Note(val name) : Parcelable
Why do we even need to parcelize this data class?为什么我们甚至需要打包这些数据 class?
You should not need to add @Parcelize
, but you may want to add the @Json
annotation to the field.您不需要添加
@Parcelize
,但您可能希望将@Json
注释添加到该字段。 Also, you were missing the type of the property name
.此外,您缺少属性
name
的类型。
@JsonClass(generateAdapter = true)
data class Note(
@field:Json(name = "name")
val name: String
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.