robercoding
02/09/2023, 4:06 PMString
or a List<String>
, if I get the response and use response.body<MyClass>()
For instance this is MyClass
@Serializable
data class MyClass(
val parameter: String // Could also be List<String>
)
Of course this fails to serialize because there's an illegal input, expect a specific type not both.
This crashes when finds that there's some parameter in the json that is a List<String>
I was thinking of ways to solve it, and the first thought was setting Any
but, of course, breaks the serialisation laws.
Then I thought that maybe I can do some custom deserialization but I don't wanna spend too much time shooting my shot in the dark.
Do you know if that's the way or is there any other better approach?Aleksei Tirman [JB]
02/09/2023, 4:54 PMrobercoding
02/09/2023, 4:57 PMJsonElement
removes any headache!! Thank you 😉
and try to convert it twice by catching the serialization exception.Just curious, is there any example for this? I wonder how much effort would involve in doing this
Aleksei Tirman [JB]
02/09/2023, 6:42 PMList<MyClass>
or MyClass
.