When you try to deserialize a collection of Eithers, the EitherModule fails with the following exception:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize [simple type, class arrow.core.Either<java.lang.String,java.lang.Integer>]. Make sure json fields are valid: [left, right].
Simple code sample demonstrating the issue:
import arrow.core.Either
import arrow.integrations.jackson.module.registerArrowModule
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
class App {
private val objectMapper = ObjectMapper()
.registerArrowModule()
.registerKotlinModule()
val demo: Unit
get() {
val eitherList: List<Either<String, Int>> = listOf(
Either.Right(10),
Either.Left("left")
)
val eitherListJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(eitherList)
println(eitherListJson)
val eitherListJsonResult: MutableSet<Either<String, Int>> = objectMapper.readValue(eitherListJson)
println(eitherListJsonResult)
}
}
fun main() {
App().demo
}
When you try to deserialize a collection of
Either
s, theEitherModule
fails with the following exception:com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize [simple type, class arrow.core.Either<java.lang.String,java.lang.Integer>]. Make sure json fields are valid: [left, right].
Simple code sample demonstrating the issue:
I will submit PR. Thanks