A specialization of ObjectSerializer for JSON serialization using a JsonGenerator.
This interface provides type-safe serialization for objects of type T
specifically to JSON. It inherits all serialization behavior and contract
from ObjectSerializer, but fixes the generator type to JsonGenerator.
Example
class UserSerializer extends JsonSerializer<User> {
@override
void serialize(User value, JsonGenerator generator, SerializerProvider serializer) {
generator.writeStartObject();
generator.writeField("id", value.id);
generator.writeField("name", value.name);
generator.writeEndObject();
}
}
See Also
- Implemented types
- Annotations
-
- @Generic.new(JsonSerializer)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canSerialize(
Class type) → bool -
Returns whether the given
typecan be serialized by the system.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
T value, JsonGenerator generator, JsonSerializationContext serializer) → void -
Serializes an object of type
Tinto an object using the provided Generator and SerializationContext.inherited -
supportsContext(
SerializationContext< Generator> context) → bool -
Determines whether this serializer supports the given serialization context.
inherited
-
toClass(
) → Class< T> -
Provides a contract for types capable of exposing their associated
runtime
Classmetadata representation within the JetLeaf reflection system.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited