|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasterxml.jackson.databind.util.JSONWrappedObject
public class JSONWrappedObject
General-purpose wrapper class that can be used to decorate serialized value with arbitrary literal prefix and suffix. This can be used for example to construct arbitrary Javascript values (similar to how basic function name and parenthesis are used with JSONP).
JSONPObject
Field Summary | |
---|---|
protected String |
_prefix
Literal String to output before serialized value. |
protected JavaType |
_serializationType
Optional static type to use for serialization; if null, runtime type is used. |
protected String |
_suffix
Literal String to output after serialized value. |
protected Object |
_value
Value to be serialized as JSONP padded; can be null. |
Constructor Summary | |
---|---|
JSONWrappedObject(String prefix,
String suffix,
Object value)
|
|
JSONWrappedObject(String prefix,
String suffix,
Object value,
JavaType asType)
Constructor that should be used when specific serialization type to use is important, and needs to be passed instead of just using runtime (type-erased) type of the value. |
Method Summary | |
---|---|
String |
getPrefix()
|
JavaType |
getSerializationType()
|
String |
getSuffix()
|
Object |
getValue()
|
void |
serialize(com.fasterxml.jackson.core.JsonGenerator jgen,
SerializerProvider provider)
Serialization method called when no additional type information is to be included in serialization. |
void |
serializeWithType(com.fasterxml.jackson.core.JsonGenerator jgen,
SerializerProvider provider,
TypeSerializer typeSer)
Serialization method called when additional type information is expected to be included in serialization, for deserialization to use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final String _prefix
protected final String _suffix
protected final Object _value
protected final JavaType _serializationType
Constructor Detail |
---|
public JSONWrappedObject(String prefix, String suffix, Object value)
public JSONWrappedObject(String prefix, String suffix, Object value, JavaType asType)
Method Detail |
---|
public void serializeWithType(com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
JsonSerializable
Usually implementation consists of a call to one of methods
in TypeSerializer
(such as TypeSerializer.writeTypePrefixForObject(Object, JsonGenerator)
)
followed by serialization of contents,
followed by another call to TypeSerializer
(such as TypeSerializer.writeTypeSuffixForObject(Object, JsonGenerator)
).
Exact methods to call in TypeSerializer
depend on shape of JSON Object used
(Array, Object or scalar like String/Number/Boolean).
Note that some types (most notably, "natural" types: String, Integer, Double and Boolean) never include type information.
serializeWithType
in interface JsonSerializable
IOException
com.fasterxml.jackson.core.JsonProcessingException
public void serialize(com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
JsonSerializable
serialize
in interface JsonSerializable
IOException
com.fasterxml.jackson.core.JsonProcessingException
public String getPrefix()
public String getSuffix()
public Object getValue()
public JavaType getSerializationType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |