AnalysisNavigationParams.fromJson constructor
AnalysisNavigationParams.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory AnalysisNavigationParams.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String file;
if (json.containsKey('file')) {
file = jsonDecoder.decodeString('$jsonPath.file', json['file']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'file');
}
List<NavigationRegion> regions;
if (json.containsKey('regions')) {
regions = jsonDecoder.decodeList(
'$jsonPath.regions',
json['regions'],
(String jsonPath, Object? json) =>
NavigationRegion.fromJson(jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'regions');
}
List<NavigationTarget> targets;
if (json.containsKey('targets')) {
targets = jsonDecoder.decodeList(
'$jsonPath.targets',
json['targets'],
(String jsonPath, Object? json) =>
NavigationTarget.fromJson(jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'targets');
}
List<String> files;
if (json.containsKey('files')) {
files = jsonDecoder.decodeList(
'$jsonPath.files', json['files'], jsonDecoder.decodeString);
} else {
throw jsonDecoder.mismatch(jsonPath, 'files');
}
return AnalysisNavigationParams(file, regions, targets, files);
} else {
throw jsonDecoder.mismatch(jsonPath, 'analysis.navigation params', json);
}
}