Skip to content

Instantly share code, notes, and snippets.

@mnn
mnn / Udash_JSON_GenCodec[Option[T]].scala
Created April 1, 2017 05:59
Udash Option JSON codec
/**
* Udash Option JSON codec for (de)serializing it this way:
* Some(x) will be serialized as x.
* None will be serialized as null.
*/
implicit def optionCodec[T: GenCodec]: GenCodec[Option[T]] =
create[Option[T]](
i => i.inputType match {
case InputType.Null =>
i.readNull()