Open d6y opened 5 years ago
Hey, the way it is currently implemented is not configurable: https://github.com/julienrf/play-json-derived-codecs/blob/master/library/src/main/scala/julienrf/json/derived/DerivedOWrites.scala#L37-L44.
Maybe it is possible to do what you want by introducing a custom implicit rule and playing with the priorities to get it right!
Otherwise, Iām happy to merge a PR making this behaviour configurable (like we currently do with the NameAdapter
and TypeTagOWrites
)!
Thank you @julienrf
Looks like I can implement a local scope version of owritesLabelledHListOpt
and replace...
case None => Map.empty
...with...
case None => Map(adaptedName -> JsNull)
...to get the behaviour I need in this case š»
Hello š
For a case class with an optional value set to
None
:...is it possible to customise derive to preserve the
None
values in the JSON?E.g., to get:
This is possibly related to the Play note on Customize the macro to output null (hmm, if that link doesn't take you to the right section, scroll to the bottom of the page).