java.lang.Object
tools.jackson.databind.util.JSONWrappedObject
- All Implemented Interfaces:
JacksonSerializable
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).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
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, 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
Modifier and TypeMethodDescriptiongetValue()voidserialize(JsonGenerator g, SerializationContext provider) Serialization method called when no additional type information is to be included in serialization.voidserializeWithType(JsonGenerator g, SerializationContext provider, TypeSerializer typeSer) Serialization method called when additional type information is expected to be included in serialization, for deserialization to use.
-
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
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 Details
-
serializeWithType
public void serializeWithType(JsonGenerator g, SerializationContext provider, TypeSerializer typeSer) throws JacksonException Description copied from interface:JacksonSerializableSerialization method called when additional type information is expected to be included in serialization, for deserialization to use.Usually implementation consists of a call to
TypeSerializer.writeTypePrefix(tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext, tools.jackson.core.type.WritableTypeId)followed by serialization of contents, followed by a call toTypeSerializer.writeTypeSuffix(tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext, tools.jackson.core.type.WritableTypeId)). Details of the type id argument to pass 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.
- Specified by:
serializeWithTypein interfaceJacksonSerializable- Throws:
JacksonException
-
serialize
Description copied from interface:JacksonSerializableSerialization method called when no additional type information is to be included in serialization.- Specified by:
serializein interfaceJacksonSerializable- Throws:
JacksonException
-
getPrefix
-
getSuffix
-
getValue
-
getSerializationType
-