Skip to content

Instantly share code, notes, and snippets.

@drstevens
Forked from debasishg/gist:b2bb9e12f9de6f601d86
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drstevens/6e69d80eefda1ed1bb65 to your computer and use it in GitHub Desktop.
Save drstevens/6e69d80eefda1ed1bb65 to your computer and use it in GitHub Desktop.
trait Writes[T] {
def writes(o: T): JsValue
}
trait Reads[T] {
def reads(json: JsValue): T
}
trait Format[T] extends Writes[T] with Reads[T]
object JsonSerialization {
def tojson[T](o: T)(implicit tjs: Writes[T]): JsValue = tjs.writes(o)
def fromjson[T](json: JsValue)(implicit fjs: Reads[T]): T = fjs.reads(json)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment