zio-json
zio-json copied to clipboard
Option field appears as null in serialized json when importing io.json.JsonCodec._
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