https://kotlinlang.org logo
#serialization
Title
# serialization
d

Distractic

11/04/2023, 1:05 AM
Hello ! I want to decode an error, but the response from an external API is .. changeable.. Once, I receive the errors like :
Copy code
{
"errors":[..]
}
And another time
Copy code
{
  "data": {
    "error": ".."
  }
}
For the moment, I'm decoding to JsonElement and read each cases. But is there a way to do that automatically with the annotations ?
d

Distractic

11/04/2023, 1:21 AM
I think first is more adapted, thanks a lot !