I am writing a Customer Serializer. In that Serializer I would like to somehow say: "and this thing you already know how to serialize".
My current approach looks like that:
import org.json4s.native.Serialization._
import org.json4s.JsonDSL.WithBigDecimal._
object WindowSerializer extends CustomSerializer[Window](format =>
( [omitted],
{
case Window(frame, size) =>
( "size" -> size ) ~
( "frame" -> parse(write(frame)) )
}))
That parse(write(frame))
things is both ugly and inefficient. How to fix that?
You can call
Extraction.decompose(a: Any)(implicit formats: Formats): JValue
which produces aJValue
from some value using runtime reflection.