ExistingImports.fromJson constructor

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

Implementation

factory ExistingImports.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    ImportedElementSet elements;
    if (json.containsKey('elements')) {
      elements = ImportedElementSet.fromJson(
          jsonDecoder, '$jsonPath.elements', json['elements']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'elements');
    }
    List<ExistingImport> imports;
    if (json.containsKey('imports')) {
      imports = jsonDecoder.decodeList(
          '$jsonPath.imports',
          json['imports'],
          (String jsonPath, Object? json) =>
              ExistingImport.fromJson(jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'imports');
    }
    return ExistingImports(elements, imports);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ExistingImports', json);
  }
}