PrioritizedSourceChange.fromJson constructor

PrioritizedSourceChange.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory PrioritizedSourceChange.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  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'],
        clientUriConverter: clientUriConverter,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'change');
    }
    return PrioritizedSourceChange(priority, change);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'PrioritizedSourceChange', json);
  }
}