Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.util

public Class JSONWrappedObject

extends Object
implements JsonSerializable
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.JsonSerializable
Imports
java.io.IOException, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.jsontype.TypeSerializer

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
com.fasterxml.jackson.databind.util.JSONPObject

Field Summary

Modifier and TypeField and Description
protected final String
_prefix

Literal String to output before serialized value.

protected final JavaType
_serializationType

Optional static type to use for serialization; if null, runtime type is used.

protected final String
_suffix

Literal String to output after serialized value.

protected final Object
_value

Value to be serialized as JSONP padded; can be null.

Constructor Summary

AccessConstructor and Description
public
JSONWrappedObject(String prefix, String suffix, Object value)

public
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 TypeMethod and Description
public String
public JavaType
public String
public Object
public void
serialize(JsonGenerator jgen, SerializerProvider provider)

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Serialization method called when no additional type information is to be included in serialization.
public void
serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Serialization method called when additional type information is expected to be included in serialization, for deserialization to use.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_prefixback to summary
protected final String _prefix

Literal String to output before serialized value. Will not be quoted when serializing value.

_serializationTypeback to summary
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).

_suffixback to summary
protected final String _suffix

Literal String to output after serialized value. Will not be quoted when serializing value.

_valueback to summary
protected final Object _value

Value to be serialized as JSONP padded; can be null.

Constructor Detail

JSONWrappedObjectback to summary
public JSONWrappedObject(String prefix, String suffix, Object value)
JSONWrappedObjectback to summary
public 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 Detail

getPrefixback to summary
public String getPrefix()
getSerializationTypeback to summary
public JavaType getSerializationType()
getSuffixback to summary
public String getSuffix()
getValueback to summary
public Object getValue()
serializeback to summary
public void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Doc from com.fasterxml.jackson.databind.JsonSerializable.serialize.

Serialization method called when no additional type information is to be included in serialization.

Annotations
@Override
serializeWithTypeback to summary
public void serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Doc from com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Serialization 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 followed by serialization of contents, followed by a call to TypeSerializer#writeTypeSuffix). 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.

Annotations
@Override