I need to get a simple JSON serialization solution with minimum ceremony. So I was quite happy finding this forthcoming Play 2.2 library. This works perfectly with plain cas
Play 2.7
sealed traits
are supported in play-json
.
object Foo{
implicit val format = Json.format[Foo]
}
Play 2.6
This can be done now elegantly with play-json-derived-codecs
Just add this:
object Foo{
implicit val jsonFormat: OFormat[Foo] = derived.oformat[Foo]()
}
See here for the whole example: ScalaFiddle