You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the Firebase library or API you need missing? [Create an issue](https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/new?labels=API+coverage&template=increase-api-coverage.md&title=Add+%5Bclass+name%5D.%5Bfunction+name%5D+to+%5Blibrary+name%5D+for+%5Bplatform+names%5D) to request additional API coverage or be awesome and [submit a PR](https://github.com/GitLiveApp/firebase-kotlin-sdk/fork)
31
31
@@ -70,8 +70,8 @@ The Firebase Kotlin SDK uses Kotlin serialization to read and write custom class
70
70
71
71
```groovy
72
72
plugins {
73
-
kotlin("multiplatform") version "1.8.21" // or kotlin("jvm") or any other kotlin plugin
74
-
kotlin("plugin.serialization") version "1.8.21"
73
+
kotlin("multiplatform") version "1.9.20" // or kotlin("jvm") or any other kotlin plugin
74
+
kotlin("plugin.serialization") version "1.9.20"
75
75
}
76
76
```
77
77
@@ -85,13 +85,43 @@ data class City(val name: String)
85
85
Instances of these classes can now be passed [along with their serializer](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#introduction-to-serializers) to the SDK:
86
86
87
87
```kotlin
88
-
db.collection("cities").document("LA").set(City.serializer(), city, encodeDefaults =true)
The `encodeDefaults` parameter is optional and defaults to `true`, set this to false to omit writing optional properties if they are equal to theirs default values.
91
+
The `buildSettings` closure is optional and allows for configuring serialization behaviour.
92
+
93
+
Setting the `encodeDefaults` parameter is optional and defaults to `true`, set this to false to omit writing optional properties if they are equal to theirs default values.
92
94
Using [@EncodeDefault](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-encode-default/) on properties is a recommended way to locally override the behavior set with `encodeDefaults`.
93
95
94
-
You can also omit the serializer but this is discouraged due to a [current limitation on Kotlin/JS and Kotlin/Native](https://github.com/Kotlin/kotlinx.serialization/issues/1116#issuecomment-704342452)
96
+
You can also omit the serializer if it can be inferred using `serializer<KType>()`.
97
+
To support [contextual serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#contextual-serialization) or [open polymorphism](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#open-polymorphism) the `serializersModule` can be overridden in the `buildSettings` closure:
98
+
99
+
```kotlin
100
+
@Serializable
101
+
abstractclassAbstractCity {
102
+
abstractval name:String
103
+
}
104
+
105
+
@Serializable
106
+
@SerialName("capital")
107
+
data classCapital(overridevalname:String, valisSeatOfGovernment:Boolean) : AbstractCity()
.let { FirebaseCompositeEncoder(shouldEncodeElementDefault, { value = it.chunked(2).associate { (k, v) -> k to v } }) { _, _, value -> it.add(value) } }
0 commit comments