JsonArrayNode class

Represents a JSON array node ([...]) in the Dart JSON model.

Each element in the array is a JsonNode, allowing hierarchical JSON structures to be constructed programmatically.

Usage Example

final arrayNode = JsonArrayNode();
arrayNode.add(JsonTextNode('Alice'));
arrayNode.add(JsonNumberNode(30));

final first = arrayNode.elements.first;
print(first.toObject()); // 'Alice'

final list = arrayNode.toObject();
print(list); // ['Alice', 30]

Behavior Overview

Dart JSON Array Internal Representation Description
[] _elements empty list Empty array
[1, 2, 3] _elements = [JsonNumberNode(1), ...] Simple numeric array
[{"a":1}, "text"] Nested object and string nodes Mixed types supported

Design Notes

  • Maintains elements in a List<JsonNode> to preserve order.
  • Supports programmatic addition via add.
  • toObject converts the node and all nested nodes to native Dart objects recursively.
  • Type-checking is consistent with JsonNode methods.
Implemented types

Constructors

JsonArrayNode()
Represents a JSON array node ([...]) in the Dart JSON model.

Properties

elements List<JsonNode>
Returns a read-only view of the elements in this array.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(JsonNode value) → void
Adds a JsonNode to the end of this JSON array.
isArray() bool
Returns true if this node represents a JSON array ([...]).
override
isBoolean() bool
Returns true if this node represents a JSON boolean (true or false).
override
isNull() bool
Returns true if this node represents a JSON null.
override
isNumber() bool
Returns true if this node represents a JSON number.
override
isObject() bool
Returns true if this node represents a JSON object ({...}).
override
isTextual() bool
Returns true if this node represents a JSON string.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toObject() List
Generic interface representing a parsed node in JetLeaf's structured data model (JSON/YAML/other).
override
toString() String
A string representation of this object.
inherited

Operators

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