You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
case class Foo(value: Option[Long])
val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
val json = """{ "value": "xx" }"""
val result = mapper.readValue[Foo](json)
println(result.value)
Instead of failing to deserialize the json (as it would occur without the option), it actually deserialize it and produces a weird object.
The println() outputs Some(xx) which does not make much sense for an Option[Long] ;-)
Using the debugger, I can see the actual runtime object in the Option is in fact a string.
The text was updated successfully, but these errors were encountered:
mdespriee
changed the title
Bad (and weird) deserialization of Option[]
Deserializaition of an Option[] not failing on bad input, returning weird data instead.
Jul 31, 2020
Tested with version 2.11.1
Instead of failing to deserialize the json (as it would occur without the option), it actually deserialize it and produces a weird object.
The println() outputs
Some(xx)
which does not make much sense for an Option[Long] ;-)Using the debugger, I can see the actual runtime object in the Option is in fact a string.
The text was updated successfully, but these errors were encountered: