I'm running Play! 2.2 with scala. I am trying to serve a JSON response. The following code will serve a response as application/json
, however I want it to serve text/json
.
I found some documentation here: http://www.playframework.com/documentation/2.1.x/ScalaJsonRequests
However, the examples shown return application/json
.
Here is an example of my function in the controller:
def myContollerFunction = Action(parse.json) { request =>
(request.body \ "foo").asOpt[String].map { foo =>
Ok(Json.toJson(Map("foo" -> foo)))
}}.getOrElse {
BadRequest("foo bar")
}
}
Here is an example output from cURL:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8