Hello,
I’m trying to serialize a generic class
ApiResponse<T>
with
kotlinx.serialization
. So i’ve created a
ApiResponseSerializer
class, with help of
docs. But now i don’t understand how to use that serializer, since none of
provided methods doesn’t seem to suit to me. That is the place where i need a help.
My ApiResponse<T> is defined like:
data class ApiResponse<T>(
val data: T? = null,
val error: ApiError? = null
)
And the regular usage (in KTOR server) is
respond(
HttpStatusCode.Created,
ApiResponse(data = response.data)
)
I don’t know where i can “attach” my serializer to
data
field of my
ApiResponse
class.
Thank you in advance.