decodeList<E extends Object> method
Decode a JSON object that is expected to be a List. The decoder
is used
to decode the items in the list.
The type parameter E
is the expected type of the elements in the list.
Implementation
List<E> decodeList<E extends Object>(
String jsonPath, Object? json, JsonDecoderCallback<E> decoder) {
if (json == null) {
return <E>[];
} else if (json is List) {
var result = <E>[];
for (var i = 0; i < json.length; i++) {
result.add(decoder('$jsonPath[$i]', json[i]));
}
return result;
} else {
throw mismatch(jsonPath, 'List', json);
}
}