Node<ObjectType> class abstract interface

Generic interface representing a parsed node in Jetleaf's structured data model (JSON/YAML/other).

Node<ObjectType> is the canonical abstraction for any parsed value and intentionally maps to a native Dart type via toObject.

This interface is designed for:

  • Providing a uniform API across different node kinds (object, array, string, number, boolean, null)
  • Allowing generated or runtime parsers to expose parsed content without forcing callers to depend on parser internals
  • Enabling conversions to standard Dart collections and primitives

Usage Example

// When deserializing:
final Node<Map<String, Object?>> root = await parser.parse();
final Map<String, Object?> map = root.toObject();

// Working with arrays:
final Node<List<Object?>> arr = someNode as Node<List<Object?>>;
final list = arr.toObject();

Design Notes

  • ObjectType is the concrete Dart type produced by toObject. Implementors should guarantee the returned value conforms to that type.
  • Conversions are typically recursive: nested nodes become nested Dart collections (maps / lists).
  • The interface is intentionally minimal to keep node implementations small and easily generated for codegen use-cases.
  • Prefer returning nullable element types in collections (Object?) to reflect possible null values in parsed data.

Example Mapping

Node Kind toObject() result type
Object Map<String, Object?>
Array List<Object?>
String String
Number num
Boolean bool
Null null

See Also

  • Parser — streaming token parser that produces nodes
  • NodeMap, NodeArray, NodeString — typical node implementations
  • Jetleaf serialization/deserialization utilities
Implementers
Annotations
  • @Generic.new(Node)

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toObject() → ObjectType
Generic interface representing a parsed node in Jetleaf's structured data model (JSON/YAML/other).
toString() → String
A string representation of this object.
inherited

Operators

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