longSerializer
@ExperimentalSince(version = KotoolsTypesVersion.V5_0_1)
Returns an object responsible for serializing the Zero type as Long.
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.longSerializer()
val zero = Zero()
val encoded: String = Json.encodeToString(serializer, zero)
assertEquals("$zero", encoded)
val decoded: Zero = Json.decodeFromString(serializer, encoded)
assertEquals(zero, decoded)
Content copied to clipboard