zt
10/29/2022, 5:48 AMExpected JsonPrimitive at text, found {"runs":[{"text":"All"}]}
I'm not sure what I'm doing wrong here
internal typealias ApiText = @Serializable(ApiTextSerializer::class) String
private class ApiTextSerializer : KSerializer<String> {
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ApiText")
override fun deserialize(decoder: Decoder): String {
val input = decoder as JsonDecoder
return input.decodeJsonElement().jsonObject["runs"]!!.jsonArray.joinToString(separator = "") {
it.jsonObject["text"]!!.jsonPrimitive.content
}
}
override fun serialize(encoder: Encoder, value: String) {
throw RuntimeException("Serialization is not needed")
}
}
Ron S
10/29/2022, 9:41 AMzt
10/29/2022, 7:33 PMzt
10/29/2022, 7:57 PMRon S
10/30/2022, 10:42 AMzt
10/31/2022, 2:12 AM