AnalysisGetNavigationResult.fromJson constructor

AnalysisGetNavigationResult.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AnalysisGetNavigationResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json,
    {ClientUriConverter? clientUriConverter}) {
  json ??= {};
  if (json is Map) {
    List<String> files;
    if (json.containsKey('files')) {
      files = jsonDecoder.decodeList(
          '$jsonPath.files',
          json['files'],
          (String jsonPath, Object? json) =>
              clientUriConverter?.fromClientFilePath(
                  jsonDecoder.decodeString(jsonPath, json)) ??
              jsonDecoder.decodeString(jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'files');
    }
    List<NavigationTarget> targets;
    if (json.containsKey('targets')) {
      targets = jsonDecoder.decodeList(
          '$jsonPath.targets',
          json['targets'],
          (String jsonPath, Object? json) => NavigationTarget.fromJson(
              jsonDecoder, jsonPath, json,
              clientUriConverter: clientUriConverter));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'targets');
    }
    List<NavigationRegion> regions;
    if (json.containsKey('regions')) {
      regions = jsonDecoder.decodeList(
          '$jsonPath.regions',
          json['regions'],
          (String jsonPath, Object? json) => NavigationRegion.fromJson(
              jsonDecoder, jsonPath, json,
              clientUriConverter: clientUriConverter));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'regions');
    }
    return AnalysisGetNavigationResult(files, targets, regions);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'analysis.getNavigation result', json);
  }
}