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 StringLiteral String to output before serialized value.protected final JavaTypeOptional static type to use for serialization; if null, runtime type is used.protected final StringLiteral String to output after serialized value.protected final ObjectValue 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()voidserialize(JsonGenerator jgen, SerializerProvider provider) voidserializeWithType(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:
serializeWithTypein interfaceJsonSerializableWithType- Throws:
IOExceptionJsonProcessingException
-
serialize
public void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException - Specified by:
serializein interfaceJsonSerializable- Throws:
IOExceptionJsonProcessingException
-
getPrefix
-
getSuffix
-
getValue
-
getSerializationType
-
JavaType, to ensure type has been properly resolved