Skip to content

Instantly share code, notes, and snippets.

@dabd
Created April 4, 2016 10:07
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 dabd/5b8e1452bd4b5ce07aa28f03fb7aa4bb to your computer and use it in GitHub Desktop.
Save dabd/5b8e1452bd4b5ce07aa28f03fb7aa4bb to your computer and use it in GitHub Desktop.
implicit def taggedStringFormat[T]: Format[String @@ T] = new Format[String @@ T] {
def reads(json: JsValue): JsResult[String @@ T] = json match {
case JsString(v) => JsSuccess(tag[T](v))
case unknown => JsError(s"String value expected, got: $unknown")
}
def writes(v: String @@ T): JsValue = JsString(v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment