playframework/Play20 — pull request #205 by julienrf (2012-03-26 15:34:00+00:00)
Title: JSONP Support

Provides Java and Scala helpers to render JSONP content.

Scala example:

``` scala
def jsonp(callback: String) = Action {
val json = JsObject(List("foo" -> JsString("bar")))
Ok(Jsonp(callback, json))
}
```

Java example:

``` java
public static Result jsonpJava(String callback) {
JsonNode json = Json.parse("{ \"foo\": \"bar\" }");
return ok(jsonp(callback, json));
}
```

Provided the following request:

```
GET /action?callback=foobar
```

It will render a `text/javascript` content containing:

``` javascript
foobar({"foo":"bar"});
```