@@ -12,14 +12,14 @@ import kotlinx.serialization.descriptors.SerialDescriptor
1212import kotlinx.serialization.descriptors.StructureKind
1313
1414actual fun FirebaseDecoder.structureDecoder (descriptor : SerialDescriptor , decodeDouble : (value: Any? ) -> Double? ): CompositeDecoder = when (descriptor.kind) {
15- StructureKind .CLASS , StructureKind .OBJECT , PolymorphicKind .SEALED -> (value as Map <* , * >).let { map ->
16- FirebaseClassDecoder (decodeDouble, map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
17- }
18- StructureKind .LIST , PolymorphicKind .SEALED -> (value as List <* >).let {
19- FirebaseCompositeDecoder (decodeDouble, it.size) { _, index -> it[index] }
20- }
21- StructureKind .MAP -> (value as Map <* , * >).entries.toList().let {
22- FirebaseCompositeDecoder (decodeDouble, it.size) { _, index -> it[index/ 2 ].run { if (index % 2 == 0 ) key else value } }
23- }
24- else -> TODO (" The firebase-kotlin-sdk does not support $descriptor for serialization yet" )
25- }
15+ StructureKind .CLASS , StructureKind .OBJECT , PolymorphicKind .SEALED -> (value as Map <* , * >).let { map ->
16+ FirebaseClassDecoder (decodeDouble, map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
17+ }
18+ StructureKind .LIST , PolymorphicKind .SEALED -> (value as List <* >).let {
19+ FirebaseCompositeDecoder (decodeDouble, it.size) { _, index -> it[index] }
20+ }
21+ StructureKind .MAP -> (value as Map <* , * >).entries.toList().let {
22+ FirebaseCompositeDecoder (decodeDouble, it.size) { _, index -> it[index/ 2 ].run { if (index % 2 == 0 ) key else value } }
23+ }
24+ else -> TODO (" The firebase-kotlin-sdk does not support $descriptor for serialization yet" )
25+ }
0 commit comments