public class JSONWithPadding extends Object implements org.codehaus.jackson.map.JsonSerializableWithType
If an instance is returned by a resource method and the most acceptable media type is one of application/javascript, application/x-javascript, text/ecmascript, application/ecmascript or text/jscript then the object that is contained by the instance is serialized as JSON (if supported, using the application/json media type) and the result is wrapped around a JavaScript callback function, whose name by default is "callback". Otherwise, the object is serialized directly according to the most acceptable media type. This means that an instance can be used to produce the media types application/json, application/xml in addition to application/x-javascript.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CALLBACK_NAME |
Constructor and Description |
---|
JSONWithPadding(Object jsonSource)
Pad JSON using the default function name "callback".
|
JSONWithPadding(Object jsonSource,
String callbackName)
Pad JSON using a declared callback function name.
|
Modifier and Type | Method and Description |
---|---|
String |
getCallbackName()
Get the callback function name.
|
Object |
getJsonSource()
Get the JSON source.
|
void |
serialize(org.codehaus.jackson.JsonGenerator jgen,
org.codehaus.jackson.map.SerializerProvider provider) |
void |
serializeWithType(org.codehaus.jackson.JsonGenerator jgen,
org.codehaus.jackson.map.SerializerProvider provider,
org.codehaus.jackson.map.TypeSerializer typeSer) |
public static final String DEFAULT_CALLBACK_NAME
public JSONWithPadding(Object jsonSource)
jsonSource
- the JSON to pad.public String getCallbackName()
public Object getJsonSource()
public void serialize(org.codehaus.jackson.JsonGenerator jgen, org.codehaus.jackson.map.SerializerProvider provider) throws IOException, org.codehaus.jackson.JsonProcessingException
serialize
in interface org.codehaus.jackson.map.JsonSerializable
IOException
org.codehaus.jackson.JsonProcessingException
public void serializeWithType(org.codehaus.jackson.JsonGenerator jgen, org.codehaus.jackson.map.SerializerProvider provider, org.codehaus.jackson.map.TypeSerializer typeSer) throws IOException, org.codehaus.jackson.JsonProcessingException
serializeWithType
in interface org.codehaus.jackson.map.JsonSerializableWithType
IOException
org.codehaus.jackson.JsonProcessingException
Copyright © 2013 Oracle Corporation. All rights reserved.