Top Description Inners Methods
com.fasterxml.jackson.databind

public Interface JsonSerializable

Known Direct Implementers
com.fasterxml.jackson.databind.JsonSerializable.Base, com.fasterxml.jackson.databind.type.TypeBase, com.fasterxml.jackson.databind.util.JSONPObject, com.fasterxml.jackson.databind.util.JSONWrappedObject, com.fasterxml.jackson.databind.util.RawValue
Imports
java.io.IOException, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.jsontype.TypeSerializer

Interface that can be implemented by objects that know how to serialize themselves to JSON, using JsonGenerator (and SerializerProvider if necessary).

Note that implementing this interface binds implementing object closely to Jackson API, and that it is often not necessary to do so -- if class is a bean, it can be serialized without implementing this interface.

Note that while it is possible to just directly implement JsonSerializable, actual implementations are strongly recommended to instead extend JsonSerializable.Base.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
JsonSerializable.Base

Base class with minimal implementation, as well as couple of extension methods that core Jackson databinding makes use of.

Method Summary

Modifier and TypeMethod and Description
public void
serialize(JsonGenerator gen, SerializerProvider serializers)

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

public void
serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer)

Serialization method called when additional type information is expected to be included in serialization, for deserialization to use.

Method Detail

serializeback to summary
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException

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

serializeWithTypeback to summary
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException

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.

com.fasterxml.jackson.databind back to summary

public abstract Class JsonSerializable.Base

extends Object
implements JsonSerializable
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.JsonSerializable
Known Direct Subclasses
com.fasterxml.jackson.databind.node.InternalNodeMapper.WrapperForSerializer, com.fasterxml.jackson.databind.JsonNode

Base class with minimal implementation, as well as couple of extension methods that core Jackson databinding makes use of. Use of this base class is strongly recommended over directly implementing JsonSerializable.
Since
2.6

Constructor Summary

AccessConstructor and Description
public
Base()

Method Summary

Modifier and TypeMethod and Description
public boolean
isEmpty(SerializerProvider serializers)

Method that may be called on instance to determine if it is considered "empty" for purposes of serialization filtering or not.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Baseback to summary
public Base()

Method Detail

isEmptyback to summary
public boolean isEmpty(SerializerProvider serializers)

Method that may be called on instance to determine if it is considered "empty" for purposes of serialization filtering or not.