dave08
12/12/2022, 12:23 PMAleksei Tirman [JB]
12/12/2022, 12:43 PMsetBody
?dave08
12/12/2022, 12:44 PMdave08
12/12/2022, 1:32 PMdave08
12/12/2022, 1:34 PMKevin Del Castillo
12/12/2022, 2:01 PM/**
* Decode the body content from this request into a [String] in UTF-8.
*/
suspend fun OutgoingContent.decodeContent(): String =
toByteArray().decodeToString()
/**
* Decode the body content from a [String] in UTF-8 into a serializable type [T].
*/
@JvmName("decodeContentSerialization")
suspend inline fun <reified T> OutgoingContent.decodeContent(): T =
Json.decodeFromString(decodeContent())
dave08
12/12/2022, 2:04 PMdave08
12/12/2022, 2:04 PMAleksei Tirman [JB]
12/12/2022, 2:05 PMKevin Del Castillo
12/12/2022, 2:05 PMdecodeFromString
is an extension function for Json
:
import kotlinx.serialization.decodeFromString
dave08
12/12/2022, 2:05 PMdave08
12/12/2022, 2:13 PM