# serialization

Angelo Rüggeberg

08/17/2022, 9:50 PM
hey, I feel super stupid as I fail to formulate a proper search 😄 I need to define a type that takes a generic. The issue is that I do get the target Type as argument (I am creating a retrofit converter but its not a retrofit specific question, just to mention some context). This is my generic class I want to serialize:
Copy code
data class Envelope<T> (
   val response: T
this is the method where i need to instance the generic typed method:
Copy code
override fun responseBodyConverter(
            type: Type,
            annotations: Array<Annotation>,
            retrofit: Retrofit
        ): Converter<ResponseBody, *>? {
I cannot find any way to create a parameterized Class with type as
parameter. I'd need something like this:
Copy code
val response : Envelope<type> = json.decodeFromString(...)