decodeJsonTree method

  1. @override
T decodeJsonTree(
  1. Object? json
)
override

Converts json (any JSON tree) to an instance of T.

Throws ArgumentError if the JSON does not match.

Implementation

@override
T decodeJsonTree(Object? json) {
  final values = this.values;
  if (json is String) {
    return decodeString(json);
  } else if (json is num) {
    final searchedIndex = json.toInt();
    RangeError.checkValidIndex(
      searchedIndex,
      values,
      'values',
      values.length,
    );
    return values[searchedIndex];
  } else {
    throw ArgumentError.value(json);
  }
}