https://kotlinlang.org logo
Title
d

Damien O'Reilly

04/15/2019, 1:11 PM
Anyone now of a nice way to do this, I am interacting with a API, and apart from the expected response , it can give about 3 different body responses in case of an error, depending on the error. Is there any way I can with gson or moshi, attempt to deserialize to one object type, and if fail, try the next one. Similar to how circe's
attemptAs
work in the scala world.
:google: 1
:stackoverflow: 2
I am noticing that gson is not failing, it just attempts to deseriualize with whatever fields are present, which isn't what I want, as the 3 different problem responses have only 1 field on common