com.fasterxml.jackson.databind.util

## Class JSONWrappedObject

- java.lang.Object
- - com.fasterxml.jackson.databind.util.JSONWrappedObject

- All Implemented Interfaces:
    JsonSerializable

      public class JSONWrappedObject
      extends Object
      implements JsonSerializable

  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:
    `JSONPObject`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable

      `JsonSerializable.Base`

  - ### Field Summary

    Fields
    Modifier and Type | Field and 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 and Description
    `JSONWrappedObject(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

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getPrefix()`
    `JavaType` | `getSerializationType()`
    `String` | `getSuffix()`
    `Object` | `getValue()`
    `void` | `serialize(JsonGenerator jgen, SerializerProvider provider)` Serialization method called when no additional type information is to be included in serialization.
    `void` | `serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)` Serialization method called when additional type information is expected to be included in serialization, for deserialization to use.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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)

    - #### JSONWrappedObject

          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

    - #### serializeWithType

          public void serializeWithType(JsonGenerator jgen,
                                        SerializerProvider provider,
                                        TypeSerializer typeSer)
                                 throws IOException,
                                        JsonProcessingException

      Description copied from interface: `JsonSerializable`
      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(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.core.type.WritableTypeId)` followed by serialization of contents, followed by a call to `TypeSerializer.writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.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:
        `serializeWithType` in interface `JsonSerializable`
      Throws:
        `IOException`
        `JsonProcessingException`

    - #### serialize

          public void serialize(JsonGenerator jgen,
                                SerializerProvider provider)
                         throws IOException,
                                JsonProcessingException

      Description copied from interface: `JsonSerializable`
      Serialization method called when no additional type information is to be included in serialization.
      Specified by:
        `serialize` in interface `JsonSerializable`
      Throws:
        `IOException`
        `JsonProcessingException`

    - #### getPrefix

          public String getPrefix()

    - #### getSuffix

          public String getSuffix()

    - #### getValue

          public Object getValue()

    - #### getSerializationType

          public JavaType getSerializationType()

Copyright © 2008–2020 FasterXML. All rights reserved.