bizzabo / play-json-extensions

+22 field case class formatter and more for play-json
http://cvogt.org/play-json-extensions/api/
Other
196 stars 44 forks source link

Support for OptionHandlers #78

Open ksceriath opened 4 years ago

ksceriath commented 4 years ago

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?