decodeJsonTree method

  1. @override
Map<K, V> 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
Map<K, V> decodeJsonTree(Object? json) {
  if (json is Map<String, dynamic>) {
    return json.map((key, value) {
      return MapEntry<K, V>(
        keyKind.decodeString(key),
        valueKind.decodeJsonTree(value),
      );
    });
  }
  throw JsonDecodingError.expectedObject(json);
}