GetValueReply.fromJson constructor

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

Creates a GetValueReply 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.value) in the json. Throws a InvalidJsonSchemaException if some values doesn't match the expected value type.

Implementation

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