How can one send, using the Play! framework, a JSON response that is formatted to be human-readable?
For example, I'm looking for something like:
def handleGET(path:String) = Action{ implicit request =>
val json = doSomethingThatReturnsAJson(path,request)
request.getQueryString("pretty") match {
case Some(_) => //some magic that will beautify the response
case None => Ok(json)
}
}
My search led me to JSON pretty-print, which was not very helpful on it's own, but it did say the ability should be integrated in future versions. That was play 2.1.X, so, I guess it already exists somewhere in the 2.2X version of play?
pretty
flag as a query param, you'll get the result beautified. benefits? it's readable. and sometimes you'll want to see a human readable representation of your'e data. take a look at elasticsearch for example. they do just that. by supplying a pretty flag, you can see all sort of data on your node/cluster. this is quite usefull. – Seicento