JsonConverter<T extends ObjectSerializable> class
Annotation used to associate a custom JSON converter with a class field or property.
This is especially useful when a field cannot be serialized or deserialized using the default behavior and needs a specific ObjectSerializable implementation.
The converter should point to a class that extends ObjectSerializable<T>.
Example:
class MyModel {
@JsonConverter(type: ClassType<DateTimeAdapter>(null, "package:jetleaf_lang/lang.dart"))
final DateTime createdAt;
MyModel(this.createdAt);
}
When deserializing MyModel, the DateTimeAdapter will be used to convert
the createdAt field instead of the default strategy.
This annotation is part of the Jetleaf Reflection system.
- Annotations
-
- @Generic.new(JsonConverter)
- @Target.new({TargetKind.field, TargetKind.getter, TargetKind.setter})
Constructors
-
JsonConverter({ObjectSerializable? converter, ClassType<
T> ? type}) -
Creates a new JsonConverter annotation.
const
Properties
- annotationType → Type
-
Returns the annotation _type of this annotation.
no setter
- converter → ObjectSerializable?
-
Optional instance of a converter to use directly.
final
- hashCode → int
-
Returns a hash code consistent with equality definition.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
type
→ ClassType<
T> ? -
The type of the converter class to use for (de)serialization.
final
Methods
-
equals(
Object other) → bool -
Checks whether the given object is logically equivalent to this annotation.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation of this annotation.
inherited
Operators
-
operator ==(
Object other) → bool -
Checks if this annotation is equal to another object.
inherited