SourceEdit.fromJson constructor

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

Implementation

factory SourceEdit.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json,
    {ClientUriConverter? clientUriConverter}) {
  json ??= {};
  if (json is Map) {
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int length;
    if (json.containsKey('length')) {
      length = jsonDecoder.decodeInt('$jsonPath.length', json['length']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'length');
    }
    String replacement;
    if (json.containsKey('replacement')) {
      replacement = jsonDecoder.decodeString(
          '$jsonPath.replacement', json['replacement']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'replacement');
    }
    String? id;
    if (json.containsKey('id')) {
      id = jsonDecoder.decodeString('$jsonPath.id', json['id']);
    }
    String? description;
    if (json.containsKey('description')) {
      description = jsonDecoder.decodeString(
          '$jsonPath.description', json['description']);
    }
    return SourceEdit(offset, length, replacement,
        id: id, description: description);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'SourceEdit', json);
  }
}