Sourabh Rawat
07/18/2021, 8:48 PMbody, which is of type Any ?
When I do something like this, it fails..
@Serializable
class Foo(val bar: String)
@Test
fun test() {
val any: Any = Foo("asd")
Json.encodeToString(any).also { println(it) }
}Aleksei Tirman [JB]
07/19/2021, 12:22 PMSourabh Rawat
07/19/2021, 7:06 PMprivate suspend inline fun <reified V> MethodData.call(): V {
return <http://httpClient.post|httpClient.post> {
url(endpoint(token, id))
contentType(ContentType.Application.Json)
body = this@call
}
}
above has body type of Any
MethodData is interface.
I call call method on subclasses of MethodData but in the scope of call it is denoted by MethodData. I believe same thing is happening in my above code. But it is failing for my code, where as ktor is able to encode the body.Aleksei Tirman [JB]
07/20/2021, 8:17 AMOutgoingContent object depending on a body's actual type.Sourabh Rawat
07/20/2021, 8:19 AMcontent = null since ContentType is neither Plain/ByteArray/ByteReadChannel ?Aleksei Tirman [JB]
07/20/2021, 8:27 AMJsonFeature installed then it will return TextContent object earlier (a serializer will be determined on this line).Sourabh Rawat
07/20/2021, 1:13 PM