Package org.codehaus.jackson.map.util
Class JSONWrappedObject
java.lang.Object
org.codehaus.jackson.map.util.JSONWrappedObject
- All Implemented Interfaces:
JsonSerializable
,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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
Literal String to output before serialized value.protected final JavaType
Optional static type to use for serialization; if null, runtime type is used.protected final String
Literal String to output after serialized value.protected final Object
Value to be serialized as JSONP padded; can be null. -
Constructor Summary
ConstructorsConstructorDescriptionJSONWrappedObject
(String prefix, String suffix, Object value) JSONWrappedObject
(String prefix, String suffix, Object value, Class<?> rawType) Deprecated.JSONWrappedObject
(String prefix, String suffix, Object value, JavaType asType) -
Method Summary
Modifier and TypeMethodDescriptiongetValue()
void
serialize
(JsonGenerator jgen, SerializerProvider provider) void
serializeWithType
(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)
-
Field Details
-
_prefix
Literal String to output before serialized value. Will not be quoted when serializing value. -
_suffix
Literal String to output after serialized value. Will not be quoted when serializing value. -
_value
Value to be serialized as JSONP padded; can be null. -
_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 Details
-
JSONWrappedObject
-
JSONWrappedObject
-
JSONWrappedObject
Deprecated.Since 1.8; should construct with resolvedJavaType
, to ensure type has been properly resolved
-
-
Method Details
-
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
-
getSuffix
-
getValue
-
getSerializationType
-
JavaType
, to ensure type has been properly resolved