diff --git a/core/src/main/kotlin/keiyoushi/utils/Json.kt b/core/src/main/kotlin/keiyoushi/utils/Json.kt index 7501d3e2b..86820ba36 100644 --- a/core/src/main/kotlin/keiyoushi/utils/Json.kt +++ b/core/src/main/kotlin/keiyoushi/utils/Json.kt @@ -10,19 +10,19 @@ import uy.kohesive.injekt.injectLazy val jsonInstance: Json by injectLazy() /** - * Parses and serializes the String as the type . + * Parses JSON string into an object of type [T]. */ inline fun String.parseAs(json: Json = jsonInstance): T = json.decodeFromString(this) /** - * Parse and serialize the response body as the type . + * Parses the response body into an object of type [T]. */ inline fun Response.parseAs(json: Json = jsonInstance): T = - json.decodeFromStream(body.byteStream()) + use { json.decodeFromStream(body.byteStream()) } /** - * Serializes the object to a JSON String. + * Serializes the object to a JSON string. */ inline fun T.toJsonString(json: Json = jsonInstance): String = json.encodeToString(this)