提问人:BalaramNayak 提问时间:7/12/2023 更新时间:11/8/2023 访问量:255
firestore android 在保存时在自定义 Parcelable 类中添加“稳定性”字段
firestore android adding "stability" field in custom Parcelable class while saving
问:
我有一个可打包的类 Image
@Parcelize
data class Image(val id:String="",val url:String=""):Parcelable
并用于保存在 Firestore 中
val data = HashMap<String,Any>()
data["title"] = "My Title"
data["image] = Image("dgdg1","https://someimagepath")
firestore.collection("collectionname").document(documentId).set(data,SetOptions.merge()).await()
数据正在保存在Firestore中,但在“图像”中,它添加了一个额外的字段“稳定性”。输出结果是这样的
{
"title":"My Title",
"image":{
"stability":0,
"id":"dgdg1",
"url":"https://someimagepath"
}
}
为什么这个“稳定性”会自动添加到图像对象中。
答:
0赞
3 revs, 3 users 86%Robert G
#1
序列化 Firebase 使用该类。该函数采用所有类级字段、getter 及其 Parent 类和字段。在本例中,是具有名为 的 getter 方法的父类。因此,在序列化时,它包括字段。
CustomClassMapper
serialize
getters
Parcelable
getStability()
stability
有关其他信息,请参阅以下文档:
评论