Interface JsonSerializable
- All Known Implementing Classes:
ArrayNode, ArrayType, BaseJsonNode, BigIntegerNode, BinaryNode, BooleanNode, CollectionLikeType, CollectionType, ContainerNode, DecimalNode, DoubleNode, FloatNode, IntNode, IterationType, JsonNode, JSONPObject, JsonSerializable.Base, JSONWrappedObject, LongNode, MapLikeType, MapType, MissingNode, NullNode, NumericNode, ObjectNode, PlaceholderForType, POJONode, RawValue, ReferenceType, ResolvedRecursiveType, ShortNode, SimpleType, TextNode, TypeBase, ValueNode
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 Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBase class with minimal implementation, as well as couple of extension methods that core Jackson databinding makes use of. -
Method Summary
Modifier and TypeMethodDescriptionvoidserialize(com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider serializers) Serialization method called when no additional type information is to be included in serialization.voidserializeWithType(com.fasterxml.jackson.core.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 Details
-
serialize
void serialize(com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider serializers) throws IOException Serialization method called when no additional type information is to be included in serialization.- Throws:
IOException
-
serializeWithType
void serializeWithType(com.fasterxml.jackson.core.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(JsonGenerator, WritableTypeId)followed by serialization of contents, followed by a call toTypeSerializer.writeTypeSuffix(JsonGenerator, 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.
- Throws:
IOException
-