play-json-extensions icon indicating copy to clipboard operation
play-json-extensions copied to clipboard

Support for OptionHandlers

Open ksceriath opened this issue 6 years ago • 0 comments

Is there any way to write None values as null?

With play.api.libs.json.Json, I could do this:

case class Reason(name: String, flag: Option[Boolean])

implicit val conf = JsonConfiguration(optionHandlers = OptionHandlers.WritesNull)
implicit val jsonFormat = Json.format[Reason]

This would emit null for "flag" if the value is None.

Is something similar available for use with Jsonx.formatCaseClass invocation?

ksceriath avatar Jan 31 '20 07:01 ksceriath