Package org.codehaus.jackson.map.util
Class JSONWrappedObject
- java.lang.Object
-
- org.codehaus.jackson.map.util.JSONWrappedObject
-
- All Implemented Interfaces:
JsonSerializable
,JsonSerializableWithType
public class JSONWrappedObject extends Object implements JsonSerializableWithType
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).- Since:
- 1.5
- Author:
- tatu
- See Also:
JSONPObject
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description JSONWrappedObject(String prefix, String suffix, Object value)
JSONWrappedObject(String prefix, String suffix, Object value, Class<?> rawType)
Deprecated.Since 1.8; should construct with resolvedJavaType
, to ensure type has been properly resolvedJSONWrappedObject(String prefix, String suffix, Object value, JavaType asType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getPrefix()
JavaType
getSerializationType()
String
getSuffix()
Object
getValue()
void
serialize(JsonGenerator jgen, SerializerProvider provider)
void
serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)
-
-
-
Field Detail
-
_prefix
protected final String _prefix
Literal String to output before serialized value. Will not be quoted when serializing value.
-
_suffix
protected final String _suffix
Literal String to output after serialized value. Will not be quoted when serializing value.
-
_value
protected final Object _value
Value to be serialized as JSONP padded; can be null.
-
_serializationType
protected final JavaType _serializationType
Optional static type to use for serialization; if null, runtime type is used. Can be used to specify declared type which defines serializer to use, as well as aspects of extra type information to include (if any).
-
-
Constructor Detail
-
JSONWrappedObject
public JSONWrappedObject(String prefix, String suffix, Object value, JavaType asType)
-
JSONWrappedObject
@Deprecated public JSONWrappedObject(String prefix, String suffix, Object value, Class<?> rawType)
Deprecated.Since 1.8; should construct with resolvedJavaType
, to ensure type has been properly resolved
-
-
Method Detail
-
serializeWithType
public void serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException
- Specified by:
serializeWithType
in interfaceJsonSerializableWithType
- Throws:
IOException
JsonProcessingException
-
serialize
public void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException
- Specified by:
serialize
in interfaceJsonSerializable
- Throws:
IOException
JsonProcessingException
-
getPrefix
public String getPrefix()
-
getSuffix
public String getSuffix()
-
getValue
public Object getValue()
-
getSerializationType
public JavaType getSerializationType()
-
-