It depends on what you are trying to achieve. Say you have Seq[(String, String)]:
val tuples = Seq(("z", "x"), ("v", "b"))
If you are trying to serialize it like this:
{
"z" : "x",
"v" : "b"
}
Json.toJson(tuples.toMap). - , Writes, :
implicit val writer = new Writes[(String, String)] {
def writes(t: (String, String)): JsValue = {
Json.obj("something" -> t._1 + ", " + t._2)
}
}
import play.api.mvc._
import play.api.libs.json._
class MyController extends Controller {
implicit val writer = new Writes[(String, String)] {
def writes(t: (String, String)): JsValue = {
Json.obj("something" -> t._1 + ", " + t._2)
}
}
def myAction = Action { implicit request =>
val tuples = Seq(("z", "x"), ("v", "b"))
Ok(Json.toJson(tuples))
}
}