cvmocanu
09/23/2018, 12:07 PMcall.receive<List<Variable>>
It looks like the JacksonConverter ends up doing something like ``objectmapper.readValue(reader, List::class.java)``, which will obviously won't work.
It my suspicions are true, this is a big design issue in the Ktor API.
Jackson accepts a ``TypeReference`` instead of a ``Class`` precisely to suport this use case.
I guess my question is what are my options?
- writing my own converter is impossible, since I can't pass a TypeReference to call.receive
- changing the REST API is unacceptable
Is reading the request body as String and using Jackson manually my only option?orangy
Nikky
09/23/2018, 12:45 PMe5l
09/23/2018, 12:51 PMtypeInfo
because of performance reason. We consider introducing the separate way to use it in the server.cvmocanu
09/23/2018, 12:53 PMe5l
09/23/2018, 12:54 PMcvmocanu
09/23/2018, 12:55 PMcvmocanu
09/23/2018, 12:58 PMval variables: List<Variable> = restApiObjectMapper.readValue(call.receiveStream(), LIST_OF_VARIABLES)
,
where
companion object {
private val LIST_OF_VARIABLES = object : TypeReference<List<Variable>>(){}
}
rharter
09/23/2018, 2:51 PMcall.receive(listTypeInfo)
, but that would preclude the whole "content negotiation" idea (using the content type header to determine how to deserialize, this would restrict to only JSON, which might be okay in your instance)cvmocanu
09/23/2018, 7:10 PMrharter
09/23/2018, 10:09 PMAccepts
header of the client request.rharter
09/23/2018, 10:09 PMMarc Knaup
10/08/2018, 3:50 PMtypeInfo
?
I use a similar approach but try to cache instances based on `ParametrizedType`: https://github.com/fluidsonic/fluid-json/blob/c3bda8e59adb6dbb5cf3fe4f8edace9f422c033a/Sources/JSONCodableType.kt#L75
I'd love to see better generics support for .receive()
!e5l
10/08/2018, 3:51 PMMarc Knaup
10/08/2018, 3:53 PM