CompletionGetSuggestionDetailsParams.fromJson constructor

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

Implementation

factory CompletionGetSuggestionDetailsParams.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');
    }
    int id;
    if (json.containsKey('id')) {
      id = jsonDecoder.decodeInt('$jsonPath.id', json['id']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'id');
    }
    String label;
    if (json.containsKey('label')) {
      label = jsonDecoder.decodeString('$jsonPath.label', json['label']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'label');
    }
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    return CompletionGetSuggestionDetailsParams(file, id, label, offset);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'completion.getSuggestionDetails params', json);
  }
}