JsonArray class abstract

This abstract class represents the data structure of multiple JSON, and provides convenient, easy, and safe features for handling multiple JSON.

Example:

void main() {
  final response = Response(
    '''[
        {"key1": "value", "key2": 1, "key3": true},
        {"key1": "value", "key2": 1, "key3": true},
        {"key1": "value", "key2": 1, "key3": true}
      ]
    ''',
    200,
  );

  final jsonArray = JsonArray.from(response: response);

  // The forEach method makes it easy to handle repetitive processes.
  jsonArray.forEach((json) {
    print(json);
  });

  // If you are iterating and want the current index as well,
  // the enumerate method is useful.
  jsonArray.enumerate((index, json) {
    print(index);
    print(json);
  });

  // JSON can be retrieved by specifying a specific index,
  // but be aware that an exception will be thrown
  // if a non-existent index number is specified.
  print(jsonArray.get(index: 0));

  // If you don't like the structure of several nested lists,
  // you can use the flatten method to make the nested structure flat.
  // This method returns a new flattened JsonArray.
  print(jsonArray.flatten());

Constructors

JsonArray.empty()
Returns the new instance of empty JsonArray.
factory
JsonArray.from({required Response response})
Returns the new instance of JsonArray based on response.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if this json array is empty, otherwise false.
no setter
isNotEmpty bool
Returns true if this json array is not empty, otherwise false.
no setter
length int
Returns the length of this json array.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

enumerate(void action(int index, Json json)) → void
Invokes action on each index and json of this json array in iteration order.
enumerateArray(void action(int index, JsonArray jsonArray)) → void
Invokes action on each index and jsonArray of this json array in iteration order.
flatten() JsonArray
Returns the new instance of flattened JsonArray from this JsonArray.
forEach(void action(Json json)) → void
Invokes action on each json of this json array in iteration order.
forEachArray(void action(JsonArray jsonArray)) → void
Invokes action on each jsonArray of this json array in iteration order.
get({required int index}) Json
Returns the Json associated with index.
getArray({required int index}) JsonArray
Returns the JsonArray associated with index.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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