DiagnosticMessage.fromJson constructor

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

Implementation

factory DiagnosticMessage.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    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']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'location');
    }
    return DiagnosticMessage(message, location);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'DiagnosticMessage', json);
  }
}