Package play.libs
Class Jsonp
java.lang.Object
play.libs.Jsonp
- All Implemented Interfaces:
play.twirl.api.Content
The JSONP Content renders a JavaScript call of a JSON object.
Example of use, provided the following route definition:
Example of use, provided the following route definition:
GET /my-service Application.myService(callback: String)The following action definition:
public static Result myService(String callback) {
JsonNode json = ...
return ok(jsonp(callback, json));
}
And the following request:
GET /my-service?callback=fooThe response will have content type "application/javascript" and will look like the following:
foo({...});
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Jsonp
-
-
Method Details
-
body
- Specified by:
bodyin interfaceplay.twirl.api.Content
-
contentType
- Specified by:
contentTypein interfaceplay.twirl.api.Content
-
jsonp
- Parameters:
padding- Name of the callbackjson- Json content- Returns:
- A JSONP Content using padding and json.
-