Represents a node in a YAML document tree (DOM-like structure).
A YamlNode provides both hierarchical navigation and direct access to YAML data, supporting mappings (objects), sequences (arrays), and scalars (values).
Node Types
- Mapping nodes - Represent YAML key-value mappings (like maps)
- Sequence nodes - Represent YAML arrays/lists
- Scalar nodes - Represent simple values (strings, numbers, booleans)
- Alias nodes - Represent references to anchored values
Navigation
final root = tree.get('users');
final firstUser = root.get('[0]');
final name = firstUser.get('name').getText();
Example
final yaml = '''
users:
- name: Alice
age: 30
- name: Bob
age: 25
''';
final tree = parser.readTree(yaml);
final users = tree.get('users');
final alice = users.get('[0]');
print(alice.get('name').getText()); // "Alice"
print(alice.get('age').getText()); // "30"
- Implemented types
-
- Node<
ObjectType>
- Node<
- Implementers
- Annotations
-
- @Generic.new(YamlNode)
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
-
get(
String key) → YamlNode? -
Returns the child node with the given
key. -
getAll(
String key) → List< YamlNode> -
Returns all child nodes with the given
key. -
getElements(
) → List< YamlNode> - Returns the list of all child nodes in a sequence.
-
getKeys(
) → List< String> - Returns the list of all keys in a mapping node.
-
getNodeType(
) → YamlNodeType - Returns the type of this YAML node.
-
getText(
) → String? - Returns the scalar value of this node.
-
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).
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited