public class Jsonp extends java.lang.Object implements Content
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 “text/javascript” and will look like the following:
foo({...});
Constructor and Description |
---|
Jsonp(java.lang.String padding,
com.fasterxml.jackson.databind.JsonNode json) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
body() |
java.lang.String |
contentType() |
static Jsonp |
jsonp(java.lang.String padding,
com.fasterxml.jackson.databind.JsonNode json) |
public Jsonp(java.lang.String padding, com.fasterxml.jackson.databind.JsonNode json)
public java.lang.String body()
body
in interface play.api.mvc.Content
public java.lang.String contentType()
contentType
in interface play.api.mvc.Content
public static Jsonp jsonp(java.lang.String padding, com.fasterxml.jackson.databind.JsonNode json)
padding
- Name of the callbackjson
- Json content