mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 02:48:24 +01:00
Reorder parameters of JSON parsing method (#8321)
This commit is contained in:
parent
64c0d9506d
commit
073e9f94ff
@ -122,12 +122,12 @@ fun OkHttpClient.newCachelessCallWithProgress(request: Request, listener: Progre
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T> Response.parseAs(): T {
|
inline fun <reified T> Response.parseAs(): T {
|
||||||
return internalParseAs(this, typeOf<T>())
|
return internalParseAs(typeOf<T>(), this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
fun <T> internalParseAs(response: Response, type: KType): T {
|
fun <T> internalParseAs(type: KType, response: Response): T {
|
||||||
val deserializer = serializer(type) as KSerializer<T>
|
val deserializer = serializer(type) as KSerializer<T>
|
||||||
return response.body.source().use {
|
return response.body.source().use {
|
||||||
Injekt.get<Json>().decodeFromBufferedSource(deserializer, it)
|
Injekt.get<Json>().decodeFromBufferedSource(deserializer, it)
|
||||||
|
Loading…
Reference in New Issue
Block a user