EntityExportData<E extends ExportableEntity<EntityId>>.fromJson constructor

EntityExportData<E extends ExportableEntity<EntityId>>.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory EntityExportData.fromJson(Map<String, dynamic> json) {
  if (json.containsKey('entityType')) {
    var entityType = entityTypeFromString(json['type']);
    switch (entityType) {
      case EntityType.DEVICE:
        return DeviceExportData.fromJson(json) as EntityExportData<E>;
      case EntityType.RULE_CHAIN:
        return RuleChainExportData.fromJson(json) as EntityExportData<E>;
      default:
        return EntityExportData._fromJson(entityType, json);
    }
  } else {
    throw FormatException('Missing type!');
  }
}