Does retrofit2 + kotlinx-serialization support returning MutableMap<String, String?>
zzyyppqq opened this issue · 0 comments
zzyyppqq commented
Does retrofit2 + kotlinx-serialization support returning MutableMap<String, String?>
After testing, retrofit2 + converter-gson is supported
Unexpected JSON token at offset 49: Unexpected 'null' value instead of string literal at path: $['language']
JSON input: {"name":"kotlinx.serialization", "language": null}
kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 49: Unexpected 'null' value instead of string literal at path: $['language']
JSON input: {"name":"kotlinx.serialization", "language": null}
interface ApiService {
@GET("my/test")
suspend fun test(): Response<MutableMap<String, String?>>
}
@Serializable
data class Response<T>(
var code: Int = 0,
var msg: String = "",
var serverTime: Long = 0,
var data: T? = null,
)
response json:
{
"data": {
"name": "kotlinx.serialization",
"language": null
},
"code": 1,
"msg": ""
}