CompletionGetSuggestionDetailsResult.fromJson constructor

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

Implementation

factory CompletionGetSuggestionDetailsResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String completion;
    if (json.containsKey('completion')) {
      completion = jsonDecoder.decodeString(
          '$jsonPath.completion', json['completion']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'completion');
    }
    SourceChange? change;
    if (json.containsKey('change')) {
      change = SourceChange.fromJson(
          jsonDecoder, '$jsonPath.change', json['change']);
    }
    return CompletionGetSuggestionDetailsResult(completion, change: change);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'completion.getSuggestionDetails result', json);
  }
}