Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option field appears as null in serialized json when importing io.json.JsonCodec._ #388

Open
fanf opened this issue Jul 30, 2021 · 0 comments

Comments

@fanf
Copy link
Contributor

fanf commented Jul 30, 2021

There is a behavior change between zio-json 0.1 and 0.1.1: if you have import zio.json.JsonCodec._ in scope, then Option fields of case classes are displayed as null when None, so that:

case class Foo(opt: Option[String], name: String)
implicit val encFoo = DeriveJsonEncoder.gen[Foo]
Foo(None, "name").toJson // {"opt":null,"name":"name"}

https://scastie.scala-lang.org/Qrzx9jmqTsCNpNsfoytlVg

@fanf fanf changed the title Since 0.1.1, importing io.json.JsonCodec._ make Option filed appears as null in serialized json Option filed appears as null in serialized json when importing io.json.JsonCodec._ Jul 30, 2021
@fanf fanf changed the title Option filed appears as null in serialized json when importing io.json.JsonCodec._ Option field appears as null in serialized json when importing io.json.JsonCodec._ Jul 30, 2021
plokhotnyuk added a commit to plokhotnyuk/jsoniter-scala that referenced this issue Jul 31, 2021
plokhotnyuk added a commit to plokhotnyuk/jsoniter-scala that referenced this issue Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant