blob: daae7f751a3f3618a883480594f5c2073dc4833f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package moe.nea.ledger.utils.network
import com.google.gson.reflect.TypeToken
import moe.nea.ledger.Ledger
data class Response(
val source: Request,
// TODO: allow other body processors, to avoid loading everything as strings
val response: String,
val headers: Map<String, List<String>>,
) {
fun <T : Any> json(typ: TypeToken<T>): T {
return Ledger.gson.fromJson(response, typ.type)
}
fun <T : Any> json(clazz: Class<T>): T {
return Ledger.gson.fromJson(response, clazz)
}
}
|