PrioritizedSourceChange.fromJson constructor

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

Implementation

factory PrioritizedSourceChange.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    int priority;
    if (json.containsKey('priority')) {
      priority =
          jsonDecoder.decodeInt('$jsonPath.priority', json['priority']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'priority');
    }
    SourceChange change;
    if (json.containsKey('change')) {
      change = SourceChange.fromJson(
          jsonDecoder, '$jsonPath.change', json['change']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'change');
    }
    return PrioritizedSourceChange(priority, change);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'PrioritizedSourceChange', json);
  }
}