gpt4 book ai didi

android - Firebase Firestore toObject 在 bool 属性映射上失败

转载 作者:IT老高 更新时间:2023-10-28 13:46:38 26 4
gpt4 key购买 nike

在从 Firestore 中提取数据时,我使用 .toObject() 将接收到的数据映射到我的数据类中,即:

data class Img(var event_uid: String = "", var isVip: Boolean = false , var nombre: String = "", var url: String = "")

但是,映射效果不佳。我在任务中收到了字段 isVip=>true,但对象字段被映射为 false(默认值)。

snapshot data

list of mapped object

我做错了什么?

编辑:我在 Logcat 中看到了

W/Firestore: (0.6.6-dev) [zzevb]: No setter/field for isVip found on class ***.model.Img

根据Kotlin Docu :

If the name of the property starts with is, a different name mapping rule is used: the name of the getter will be the same as the property name, and the name of the setter will be obtained by replacing is with set. For example, for a property isOpen, the getter will be called isOpen() and the setter will be called setOpen(). This rule applies for properties of any type, not just Boolean.

可能是带有 Kotlin 问题的 Firestore?

最佳答案

尝试将 @field:JvmField 添加到 isValid bool 属性。

关于android - Firebase Firestore toObject 在 bool 属性映射上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52284861/

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