A helper class primary for use with the interpolator. Import
OrJNull.implicits._ to get an orJNull method on Option[T]
which encodes the value using T's JsonEncode when it's Some
and as JNull when it's None.
val x = Some(AnEncodableThing(...))
val y = Option.empty[AnEncodableThing]
json""" {
x1 : ${x.orJNull}, // These two lines
x2 : ?$x, // encode the same way.
y1 : ${y.orJNull}, // This one produces `null`.
y2 : ?$y // And this one is elided.
} """
A helper class primary for use with the interpolator. Import
OrJNull.implicits._to get anorJNullmethod onOption[T]which encodes the value usingT'sJsonEncodewhen it'sSomeand asJNullwhen it'sNone.