DeviceProfileTransportConfiguration.fromJson constructor

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

Implementation

factory DeviceProfileTransportConfiguration.fromJson(
    Map<String, dynamic> json) {
  if (json.containsKey('type')) {
    var deviceProfileType = deviceTransportTypeFromString(json['type']);
    switch (deviceProfileType) {
      case DeviceTransportType.DEFAULT:
        return DefaultDeviceProfileTransportConfiguration.fromJson(json);
      case DeviceTransportType.MQTT:
        return MqttDeviceProfileTransportConfiguration.fromJson(json);
      case DeviceTransportType.COAP:
        return CoapDeviceProfileTransportConfiguration.fromJson(json);
      case DeviceTransportType.LWM2M:
        return Lwm2mDeviceProfileTransportConfiguration.fromJson(json);
      case DeviceTransportType.SNMP:
        return SnmpDeviceProfileTransportConfiguration.fromJson(json);
    }
  } else {
    throw FormatException('Missing type!');
  }
}