Hi everyone, I'm using retrofit and I have the following question:
Will retrofit able to parse one field of the response as generic?
More details in the 🧵
class ApiResponse : ArrayList<ApiItem>()
data class ApiItem(
@SerializedName("data")
val myData: Data,
@SerializedName("type")
val type: String,
@SerializedName("version")
val version: Int
)
// how do i do
data class Data(
)
Ruben Quadros
10/31/2022, 9:28 AM
Can i make this
Data
generic? or will have have to explicitly mention each type?
Copy code
data class Data(
@SerializedName("data1)
val data1: Data1?,
@SerializedName("data2)
val data2: Data2?,
@SerializedName("data3)
val data3: Data3?
)
data class Data1()
data class Data2()
data class Data3()
a
Aditya Kurkure
10/31/2022, 9:30 AM
This would depend on the serialiser you are using and not retrofit itself right?
r
Ruben Quadros
10/31/2022, 9:31 AM
ok.. I'm using
Gson
Ruben Quadros
10/31/2022, 9:33 AM
basically if I create a custom deserializer then it should work?