Matthew Cachia
03/02/2021, 4:45 PMEither<L, R>
(which means it contains either L
or R
) with the following logic:
override fun deserialize(decoder: Decoder): Either<L, R> =
try {
rightSerializer.deserialize(decoder).right()
} catch (e: Exception) {
leftSerializer.deserialize(decoder).left()
}
• If the given JSON payload is meant for type R
, everything works well.
• If the given JSON payload is meant for type L
, the exception is caught, however the cursor in the decoder has already progressed (and thus fails to deserialize)
Is there a way to reset the decoder back to its original cursor position? Am I approaching this the wrong way? Are there alternatives?
Thank you in advance.ephemient
03/02/2021, 5:08 PMMatthew Cachia
03/02/2021, 5:55 PMJavier
01/30/2022, 12:50 AMJson
? that implies that default properties provided outside here are missingJavier
01/30/2022, 12:52 AMdecoder.json.decodeFromJsonElement(serializer, decoder.decodeJsonElement())
Javier
01/30/2022, 12:54 AMJson
usage and allowing all implementations to workephemient
01/30/2022, 12:54 AMJavier
01/30/2022, 12:54 AMephemient
01/30/2022, 1:17 AMJavier
01/30/2022, 1:59 AMephemient
01/30/2022, 2:10 AMephemient
01/30/2022, 2:13 AM