ServiceRequest.fromJson constructor

ServiceRequest.fromJson(
  1. Map<String, dynamic> json
)

Creates a ServiceRequest with the information stored in the json.

Throws a JsonMissingKeyException if there is missing one of the needed keys (BrokerKeys.identifier, BrokerKeys.receivers,BrokerKeys.sender, BrokerKeys.serviceType) in the json. Throws a InvalidJsonSchemaException if some values doesn't match the expected value type.

Implementation

factory ServiceRequest.fromJson(Map<String, dynamic> json) {
  try {
    final ServiceRequest msg = ServiceRequest()
      ..generateFromJson(json)
      ..parameters = json.containsKey(BrokerKeys.parameters)
          ? json[BrokerKeys.parameters] as Map<String, dynamic>
          : null;
    return msg;
  } on TypeError catch (e) {
    throw InvalidJsonSchemaException(
        e.stackTrace.toString(), json.toString());
  }
}