AnalysisOccurrencesParams.fromJson constructor

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

Implementation

factory AnalysisOccurrencesParams.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<Occurrences> occurrences;
    if (json.containsKey('occurrences')) {
      occurrences = jsonDecoder.decodeList(
          '$jsonPath.occurrences',
          json['occurrences'],
          (String jsonPath, Object? json) =>
              Occurrences.fromJson(jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'occurrences');
    }
    return AnalysisOccurrencesParams(file, occurrences);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'analysis.occurrences params', json);
  }
}