Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么firebase映射整数键抛出ClassCastException_Android_Firebase_Kotlin_Google Cloud Firestore - Fatal编程技术网

Android 为什么firebase映射整数键抛出ClassCastException

Android 为什么firebase映射整数键抛出ClassCastException,android,firebase,kotlin,google-cloud-firestore,Android,Firebase,Kotlin,Google Cloud Firestore,所以,在我的数据库中,我有一个类型为 当我获取它时,我得到键的值(整数)和字符串值 val time = infoSnapshot.get("opentimes") as Map<Int, String> for (entries in time.entries) { myList.add(OpenTime(entries.key, entries.value)) } 但在我的数据库中,键不是用字符串表示的,而是用数字表示的

所以,在我的数据库中,我有一个类型为

当我获取它时,我得到键的值(整数)和字符串值

 val time = infoSnapshot.get("opentimes") as Map<Int, String>
        for (entries in time.entries) {
            myList.add(OpenTime(entries.key, entries.value))
        }
但在我的数据库中,键不是用字符串表示的,而是用数字表示的


我不知道为什么我的输入键会出现这个问题

好的,我不知道这是否是Firebase的问题,但我必须将HashMap更改为
,并将Firebase中作为字符串的整数值解析为int

val time = infoSnapshot.get("opentimes") as Map<String, String>
val time=infoSnapshot.get(“opentimes”)作为映射

Firestore中的键始终是字符串而不是数字。
val time = infoSnapshot.get("opentimes") as Map<String, String>