floatSerializer

@ExperimentalSince(version = KotoolsTypesVersion.V5_0_1)
fun Zero.Companion.floatSerializer(): KSerializer<Zero>

Returns an object responsible for serializing the Zero type as Float.


Calling from Kotlin

Here's an example of Kotlin code that encodes and decodes the Zero type using the JavaScript Object Notation (JSON) format from kotlinx.serialization and this function:

val serializer: KSerializer<Zero> = Zero.floatSerializer()
val zero = Zero()
val encoded: String = Json.encodeToString(serializer, zero)
val expectedEncoding: String = zero.toFloat()
    .toString()
assertEquals(expectedEncoding, encoded)
val decoded: Zero = Json.decodeFromString(serializer, encoded)
assertEquals(zero, decoded)