All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmTest.kotlinx.serialization.test.JsonHelpers.kt Maven / Gradle / Ivy

There is a newer version: 1.7.3
Show newest version
package kotlinx.serialization.test

import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.json.*
import java.io.ByteArrayOutputStream

actual fun  Json.encodeViaStream(
    serializer: SerializationStrategy,
    value: T
): String {
    val output = ByteArrayOutputStream()
    encodeToStream(serializer, value, output)
    return output.toString()
}

actual fun  Json.decodeViaStream(
    serializer: DeserializationStrategy,
    input: String
): T = decodeFromStream(serializer, input.byteInputStream())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy