-
-
Notifications
You must be signed in to change notification settings - Fork 143
Closed
Description
case class Foo(bar: Options[String] = None)
gets written as { "bar": null }.
This used to work for me before (at least, in 2.6.6). Not sure at which point it got broken, I ran into this issue trying to upgrade to 2.8.8.
Update: Looks like the last version it works right is 2.7.3. I haven't checked everything after that, but 2.7.{4,5,9} and 2.8.0 are all broken.
Unfortunately, I cannot use 2.7.3 or 2.7.2, because they have another issue (seems to be gone in 2.8.8, so I am not reporting it separately): if I have a trait extending a Product, and a case class with a field, that's Option of that trait, then serializing that case class always writes that field as empty:
trait Prod extends Produc1[String] { def x: String; def canEqual(o: Any) = ???; def _1 = x }
class Foo(val x: String) extends Prod
case class Bar(bar: Prod)
case class Bat(bam: Option[Foo])
case class Baz(baz: Option[Prod])
mapper.writeValueAsString(new Foo("bar")) // { "x" = "bar" } - good
mapper.writeValueAsString(Bar(new Foo("bar"))) // { "bar" = { "x" = "bar" }} - good
mapper.writeValueAsString(Bat(Some(new Foo("bar")))) // { "bat" = { "x" = "bar" }} - good
mapper.writeValueAsString(Baz(Some(new Foo("bar")))) // { "baz" = {}} - ????
So, it looks like I am stuck with 2.6.6. for now ... :(
Metadata
Metadata
Assignees
Labels
No labels