DoubleDeserializer<P extends Parser, C extends DeserializationContext<Parser> > class
final
Deserializes JSON numeric values into Dart double instances.
The DoubleDeserializer converts JSON numbers and numeric-like strings into
Dart double values, applying relaxed and safe coercion rules:
- Returns the value directly if it is already a
double. - Converts any
numinto adoubleusing.toDouble(). - Attempts
double.tryParse()for string values. - Returns
nullwhen the JSON value isnull.
Core Responsibilities
- Provide safe and predictable coercion of JSON numeric values to
double. - Handle integers, doubles, numeric strings, and nulls.
- Integrate seamlessly with JetLeaf's deserialization strategy.
Example
final deserializer = DoubleDeserializer();
final parser = JsonParser('3.14');
final result = deserializer.deserialize(parser, context, Class.forType(double));
// result == 3.14
Notes
- Non-numeric strings result in
nullviadouble.tryParse. - Avoids throwing format exceptions unless upstream parser errors occur.
- Inheritance
-
- Object
- ObjectDeserializer<
double, P, C> - DoubleDeserializer
- Annotations
-
- @Generic.new(DoubleDeserializer)
Constructors
- DoubleDeserializer()
-
Creates a new DoubleDeserializer.
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
-
canDeserialize(
Class type) → bool -
Returns whether the given
typecan be deserialized by the system.override -
deserialize(
P parser, C ctxt, Class toClass) → double? -
Deserializes an object of type
Tusing the givenPand DeserializationContext.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
supports(
DeserializationContext< Parser> context) → bool -
Determines whether this deserializer supports the given deserialization context.
inherited
-
toClass(
) → Class< double> -
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