Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created December 30, 2013 22:47
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 jackdempsey/8189527 to your computer and use it in GitHub Desktop.
Save jackdempsey/8189527 to your computer and use it in GitHub Desktop.
scala> Json.toJson((1, 2))
<console>:20: error: No Json deserializer found for type (Int, Int). Try to implement an implicit Writes or Format for this type.
Json.toJson((1, 2))
^
scala> implicit val x = new Writes[(Int, Int)] {
| def writes(t: (Int, Int)): JsValue = {
| JsArray(Seq(JsNumber(t._1), JsNumber(t._2)))
| }
| }
x: play.api.libs.json.Writes[(Int, Int)] = $anon$1@62ea9973
scala> Json.toJson((1, 2))
res41: play.api.libs.json.JsValue = [1,2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment