getJsonValue<T> function
Implementation
T getJsonValue<T>(Map<String, dynamic> json, String key) {
if (!json.containsKey(key)) {
throw SchemeConsistencyException('key "$key" hasn\'t found');
} else if (json[key] is! T) {
if (T == double && json[key] is int) {
return json[key].toDouble();
} else {
throw SchemeConsistencyException(
'Wrong type by key "$key", expected: "$T" '
'but has got: "${json[key].runtimeType}"',
);
}
} else {
return json[key] as T;
}
}