AnalysisGetLibraryDependenciesResult.fromJson constructor

AnalysisGetLibraryDependenciesResult.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory AnalysisGetLibraryDependenciesResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    List<String> libraries;
    if (json.containsKey('libraries')) {
      libraries = jsonDecoder.decodeList(
          '$jsonPath.libraries', json['libraries'], jsonDecoder.decodeString);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'libraries');
    }
    Map<String, Map<String, List<String>>> packageMap;
    if (json.containsKey('packageMap')) {
      packageMap = jsonDecoder.decodeMap(
          '$jsonPath.packageMap', json['packageMap'],
          valueDecoder: (String jsonPath, Object? json) =>
              jsonDecoder.decodeMap(jsonPath, json,
                  valueDecoder: (String jsonPath, Object? json) => jsonDecoder
                      .decodeList(jsonPath, json, jsonDecoder.decodeString)));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'packageMap');
    }
    return AnalysisGetLibraryDependenciesResult(libraries, packageMap);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'analysis.getLibraryDependencies result', json);
  }
}