GetValueRequest.fromJson constructor

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

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

Implementation

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