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 num into a double using .toDouble().
  • Attempts double.tryParse() for string values.
  • Returns null when the JSON value is null.

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 null via double.tryParse.
  • Avoids throwing format exceptions unless upstream parser errors occur.
Inheritance
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 type can be deserialized by the system.
override
deserialize(P parser, C ctxt, Class toClass) double?
Deserializes an object of type T using the given P and 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 Class metadata representation within the JetLeaf reflection system.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited