serialize
Serializes the specified value using the format represented by the specified encoder.
See the KSerializer.serialize function for more details.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val serializer = ZeroAsByteSerializer()
val zero = Zero()
val encoded: String = Json.encodeToString(serializer, zero)
val expected: String = zero.toByte()
.let(Json.Default::encodeToString)
assertEquals(expected, encoded)
Content copied to clipboard