DiagnosticMessage.fromJson constructor

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

Implementation

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