@@ -1173,33 +1173,37 @@ class JsonCodecMakerSpec extends VerifyingSpec {
1173
1173
""" {"param1":"A","param2":"B","payload":{"x":[-1.0,1,4.0E20],"y":{"xx":true,"yy":false,"zz":null},"z":"Z"},"param3":"C"}""" )
1174
1174
}
1175
1175
" serialize and deserialize nested options without loss of information" in {
1176
- case class NestedOptions (x : Option [Option [Option [String ]]] = _root_.scala.None )
1176
+ case class NestedOptions (y : Option [ String ], x : Option [Option [Option [String ]]] = _root_.scala.None )
1177
1177
1178
1178
val codecOfNestedOptions = make[NestedOptions ]
1179
- verifySerDeser(codecOfNestedOptions, NestedOptions (_root_.scala.None ), """ {}""" )
1180
- verifyDeser(codecOfNestedOptions, NestedOptions (_root_.scala.None ), """ {"x":null}""" )
1181
- verifySerDeser(codecOfNestedOptions, NestedOptions (_root_.scala.Some (_root_.scala.Some (_root_.scala.Some (" VVV" )))),
1179
+ verifyDeser(codecOfNestedOptions,
1180
+ NestedOptions (_root_.scala.None , _root_.scala.None ), """ {"y":null,"x":null}""" )
1181
+ verifySerDeser(codecOfNestedOptions,
1182
+ NestedOptions (_root_.scala.Some (" VVV" ), _root_.scala.None ), """ {"y":"VVV"}""" )
1183
+ verifySerDeser(codecOfNestedOptions,
1184
+ NestedOptions (_root_.scala.None , _root_.scala.Some (_root_.scala.Some (_root_.scala.Some (" VVV" )))),
1182
1185
""" {"x":{"type":"Some","value":{"type":"Some","value":"VVV"}}}""" )
1183
- verifySerDeser(codecOfNestedOptions, NestedOptions (_root_.scala.Some (_root_.scala.None )),
1184
- """ {"x":{"type":"None"}}""" )
1185
- verifySerDeser(codecOfNestedOptions, NestedOptions (_root_.scala.Some (_root_.scala.Some (_root_.scala.None ))),
1186
+ verifySerDeser(codecOfNestedOptions,
1187
+ NestedOptions (_root_.scala.None , _root_.scala.Some (_root_.scala.None )), """ {"x":{"type":"None"}}""" )
1188
+ verifySerDeser(codecOfNestedOptions,
1189
+ NestedOptions (_root_.scala.None , _root_.scala.Some (_root_.scala.Some (_root_.scala.None ))),
1186
1190
""" {"x":{"type":"Some","value":{"type":"None"}}}""" )
1187
1191
}
1188
1192
" serialize and deserialize Option[Option[_]] to distinguish `null` field values and missing fields" in {
1189
- case class Model (field1 : Option [Option [ String ] ], field2 : Option [Option [String ]] = _root_.scala.None )
1193
+ case class Model (field1 : Option [String ], field2 : Option [Option [String ]] = _root_.scala.None )
1190
1194
1191
1195
verifySerDeser(make[List [Model ]](CodecMakerConfig .withSkipNestedOptionValues(true )),
1192
1196
List (
1193
- Model (_root_.scala.Some (_root_.scala. Some ( " VVV" ) ), _root_.scala.Some (_root_.scala.Some (" WWW" ))),
1197
+ Model (_root_.scala.Some (" VVV" ), _root_.scala.Some (_root_.scala.Some (" WWW" ))),
1194
1198
Model (_root_.scala.None ),
1195
- Model (_root_.scala.Some (_root_.scala. None ) , _root_.scala.Some (_root_.scala.None ))),
1196
- """ [{"field1":"VVV","field2":"WWW"},{},{"field1":null," field2":null}]""" )
1199
+ Model (_root_.scala.None , _root_.scala.Some (_root_.scala.None ))),
1200
+ """ [{"field1":"VVV","field2":"WWW"},{},{"field2":null}]""" )
1197
1201
verifySerDeser(makeWithSkipNestedOptionValues[List [Model ]],
1198
1202
List (
1199
- Model (_root_.scala.Some (_root_.scala. Some ( " VVV" ) ), _root_.scala.Some (_root_.scala.Some (" WWW" ))),
1203
+ Model (_root_.scala.Some (" VVV" ), _root_.scala.Some (_root_.scala.Some (" WWW" ))),
1200
1204
Model (_root_.scala.None ),
1201
- Model (_root_.scala.Some (_root_.scala. None ) , _root_.scala.Some (_root_.scala.None ))),
1202
- """ [{"field1":"VVV","field2":"WWW"},{},{"field1":null," field2":null}]""" )
1205
+ Model (_root_.scala.None , _root_.scala.Some (_root_.scala.None ))),
1206
+ """ [{"field1":"VVV","field2":"WWW"},{},{"field2":null}]""" )
1203
1207
}
1204
1208
" serialize and deserialize Nullable[_] to distinguish `null` field values and missing fields using a custom value codec" in {
1205
1209
sealed trait Nullable [+ A ]
0 commit comments