EditGetAssistsParams.fromJson constructor

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

Implementation

factory EditGetAssistsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    String file;
    if (json.containsKey('file')) {
      file =
          clientUriConverter?.fromClientFilePath(
            jsonDecoder.decodeString('$jsonPath.file', json['file']),
          ) ??
          jsonDecoder.decodeString('$jsonPath.file', json['file']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'file');
    }
    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');
    }
    return EditGetAssistsParams(file, offset, length);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'edit.getAssists params', json);
  }
}