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) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.getNavigation result'",
      json,
    );
  }
  List<String> files;
  if (json case {'files': var encodedFiles}) {
    files = jsonDecoder.decodeList(
      '$jsonPath.files',
      encodedFiles,
      (String jsonPath, Object? json) =>
          clientUriConverter?.fromClientFilePath(
            jsonDecoder.decodeString(jsonPath, json),
          ) ??
          jsonDecoder.decodeString(jsonPath, json),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'files'", json);
  }
  List<NavigationTarget> targets;
  if (json case {'targets': var encodedTargets}) {
    targets = jsonDecoder.decodeList(
      '$jsonPath.targets',
      encodedTargets,
      (String jsonPath, Object? json) => NavigationTarget.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'targets'", json);
  }
  List<NavigationRegion> regions;
  if (json case {'regions': var encodedRegions}) {
    regions = jsonDecoder.decodeList(
      '$jsonPath.regions',
      encodedRegions,
      (String jsonPath, Object? json) => NavigationRegion.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'regions'", json);
  }
  return AnalysisGetNavigationResult(files, targets, regions);
}