3 Star 33 Fork 16

抓猪 / kmvvm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
SerializationResponseBodyConverter.kt 572 Bytes
一键复制 编辑 原始数据 按行查看 历史
抓猪 提交于 2022-10-20 22:45 . 将下载模块独立成一个module
package com.catchpig.mvvm.network.converter
import com.catchpig.annotation.interfaces.SerializationConverter
import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer
import okhttp3.ResponseBody
import java.lang.reflect.Type
class SerializationResponseBodyConverter : SerializationConverter<ResponseBody, Any> {
lateinit var type: Type
override var json: Json = Json {
ignoreUnknownKeys = true
}
override fun convert(value: ResponseBody): Any? {
return json.decodeFromString(serializer(type), value.string())
}
}
Android
1
https://gitee.com/catchpig/kmvvm.git
git@gitee.com:catchpig/kmvvm.git
catchpig
kmvvm
kmvvm
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891