@@ -108,7 +108,7 @@ object JsonSpec extends ZIOSpecDefault {
108108 case class OptionalMessage (value : Option [String ]) derives Schema , ProtobufCodec
109109 val instance = OptionalMessage (None )
110110 val result = instance.asJson.noSpaces
111- assertTrue(result == """ {"value":null }""" )
111+ assertTrue(result == """ {}""" )
112112 },
113113 test(" toJson serializes optional Int" ) {
114114 case class OptionalIntMessage (value : Option [Int ]) derives Schema , ProtobufCodec
@@ -119,7 +119,7 @@ object JsonSpec extends ZIOSpecDefault {
119119 val noneJson = none.asJson.noSpaces
120120
121121 assertTrue(someJson == """ {"value":42}""" ) &&
122- assertTrue(noneJson == """ {"value":null }""" )
122+ assertTrue(noneJson == """ {}""" )
123123 }
124124 ),
125125 suite(" Message Types" )(
@@ -147,7 +147,7 @@ object JsonSpec extends ZIOSpecDefault {
147147 val withoutJson = withoutContact.asJson.noSpaces
148148
149149 assertTrue(withJson == """ {"name":"Alice","contact":{"email":"alice@test.com","phone":"123-456"}}""" ) &&
150- assertTrue(withoutJson == """ {"name":"Bob","contact":null }""" )
150+ assertTrue(withoutJson == """ {"name":"Bob"}""" )
151151 }
152152 ),
153153 suite(" Collection Types" )(
@@ -292,13 +292,13 @@ object JsonSpec extends ZIOSpecDefault {
292292
293293 assertTrue(result == """ {"intVal":0,"stringVal":"","boolVal":false}""" )
294294 },
295- test(" toJson handles null values" ) {
295+ test(" toJson omits null values" ) {
296296 case class B (c : Int ) derives Schema , ProtobufCodec
297- case class A (b : B ) derives Schema , ProtobufCodec
298- val instance = A (null )
297+ case class A (a : Int , b : B ) derives Schema , ProtobufCodec
298+ val instance = A (1 , null )
299299 val result = instance.asJson.noSpaces
300300
301- assertTrue(result == """ {"b":null }""" )
301+ assertTrue(result == """ {"a":1 }""" )
302302 },
303303 test(" toJson handles complex nested structure" ) {
304304 case class Address (street : String , city : String , zip : Option [String ]) derives Schema , ProtobufCodec
0 commit comments