Lamberto Basti
04/10/2020, 2:40 PM@Serializable
data class PagedData<T>(val data: T, val page: Int, val totalPages: Int, val pageSize: Int)
Where you know for sure that T
is a class that has the annotations @Serializable
or a list of a type that is annotated with @Serializable
.
Why the serialization runtime is not able to infer what to use? Also, I am using Ktor, it would be kind of pointless to explicitly build a serializer before every response as such.Dominaezzz
04/10/2020, 4:07 PMList<T>
had to have it's serializers explicitly created. This was "fixed" for bult-in types using the typeOf
api.
I believe support is being added to non built-in types is planned.Lamberto Basti
04/10/2020, 4:21 PMDominaezzz
04/10/2020, 4:23 PMString
from ktor the deserialize it myself with the explicitly created serializer.Lamberto Basti
04/10/2020, 4:25 PMcontent-type
header if i return just a string?Dominaezzz
04/10/2020, 4:28 PMLamberto Basti
04/10/2020, 4:40 PMcall.respond(PagedData(data, page, pageSize, totalPages))
Dominaezzz
04/10/2020, 4:41 PMDominaezzz
04/10/2020, 4:42 PMLamberto Basti
04/10/2020, 5:17 PMcall.respondText(
deserializer.stringify(
PagedData.serializer(ElaboratedTweet.serializer().list),
PagedData(data, page, pageSize, totalPages)
),
ContentType.Application.Json
)
Thanks :)