generateFromJson method

  1. @override
void generateFromJson(
  1. Map<String, dynamic> json
)

Fills this ServiceMessage 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

@override
void generateFromJson(Map<String, dynamic> json) {
  super.generateFromJson(json);
  try {
    serviceType = json.containsKey(BrokerKeys.serviceType)
        ? json[BrokerKeys.serviceType] as String
        : throw JsonMissingKeyException(
            BrokerKeys.serviceType, json.toString());
  } on TypeError catch (e) {
    throw InvalidJsonSchemaException(
        e.stackTrace.toString(), json.toString());
  }
}