RefactoringProblem.fromJson constructor

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

Implementation

factory RefactoringProblem.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    RefactoringProblemSeverity severity;
    if (json.containsKey('severity')) {
      severity = RefactoringProblemSeverity.fromJson(
        jsonDecoder,
        '$jsonPath.severity',
        json['severity'],
        clientUriConverter: clientUriConverter,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'severity');
    }
    String message;
    if (json.containsKey('message')) {
      message = jsonDecoder.decodeString(
        '$jsonPath.message',
        json['message'],
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'message');
    }
    Location? location;
    if (json.containsKey('location')) {
      location = Location.fromJson(
        jsonDecoder,
        '$jsonPath.location',
        json['location'],
        clientUriConverter: clientUriConverter,
      );
    }
    return RefactoringProblem(severity, message, location: location);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'RefactoringProblem', json);
  }
}