IntSerializer<G extends Generator, C extends SerializationContext<Generator> > class
final
Serializes Dart int values into JSON numeric values.
The IntSerializer handles integer serialization for both JSON-specific generators and generic text-based generators:
Serialization Rules
- If the active generator is a JsonGenerator, the value is emitted as a
JSON number via
writeNumber(). - For non-JSON generators, an integer is serialized as its string
representation using
writeString().
This allows the serializer to work seamlessly with multiple output formats while always maintaining correct JSON number semantics.
Example
final serializer = IntSerializer();
serializer.serialize(123, generator, context);
// JSON output: 123
Notes
- This serializer does not perform any range validation.
- For formatting requirements (e.g., padding, hex, locale formatting),
consider using a custom
JsonConverter.
- Inheritance
-
- Object
- ObjectSerializer<
int, G, C> - IntSerializer
- Annotations
-
- @Generic.new(IntSerializer)
Constructors
- IntSerializer()
-
Creates a new IntSerializer.
const
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.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
int value, G generator, C ctxt) → void -
Serializes an object of type
Tinto an object using the provided Generator and SerializationContext.override -
supportsContext(
SerializationContext< Generator> context) → bool -
Determines whether this serializer supports the given serialization context.
inherited
-
toClass(
) → Class< int> -
Provides a contract for types capable of exposing their associated
runtime
Classmetadata representation within the JetLeaf reflection system. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited