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
Constructors
- JsonArrayNode()
-
Represents a JSON array node (
[...]) in the Dart JSON model.
Properties
Methods
-
add(
JsonNode value) → void - Adds a JsonNode to the end of this JSON array.
-
isArray(
) → bool -
Returns
trueif this node represents a JSON array ([...]).override -
isBoolean(
) → bool -
Returns
trueif this node represents a JSON boolean (trueorfalse).override -
isNull(
) → bool -
Returns
trueif this node represents a JSONnull.override -
isNumber(
) → bool -
Returns
trueif this node represents a JSON number.override -
isObject(
) → bool -
Returns
trueif this node represents a JSON object ({...}).override -
isTextual(
) → bool -
Returns
trueif 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