DeviceTransportConfiguration.fromJson constructor

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

Implementation

factory DeviceTransportConfiguration.fromJson(Map<String, dynamic> json) {
  if (json.containsKey('type')) {
    var deviceTransportType = deviceTransportTypeFromString(json['type']);
    switch (deviceTransportType) {
      case DeviceTransportType.DEFAULT:
        return DefaultDeviceTransportConfiguration.fromJson(json);
      case DeviceTransportType.MQTT:
        return MqttDeviceTransportConfiguration.fromJson(json);
      case DeviceTransportType.COAP:
        return CoapDeviceTransportConfiguration.fromJson(json);
      case DeviceTransportType.LWM2M:
        return Lwm2mDeviceTransportConfiguration.fromJson(json);
      case DeviceTransportType.SNMP:
        return SnmpDeviceTransportConfiguration.fromJson(json);
    }
  } else {
    throw FormatException('Missing type!');
  }
}