EndpointSubset.fromJson constructor

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

Creates a EndpointSubset from JSON data.

Implementation

factory EndpointSubset.fromJson(Map<String, dynamic> json) {
  final tempAddressesJson = json['addresses'];
  final tempNotReadyAddressesJson = json['notReadyAddresses'];
  final tempPortsJson = json['ports'];

  final List<EndpointAddress>? tempAddresses = tempAddressesJson != null
      ? List<dynamic>.from(tempAddressesJson)
          .map(
            (e) => EndpointAddress.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final List<EndpointAddress>? tempNotReadyAddresses =
      tempNotReadyAddressesJson != null
          ? List<dynamic>.from(tempNotReadyAddressesJson)
              .map(
                (e) => EndpointAddress.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<EndpointPort>? tempPorts = tempPortsJson != null
      ? List<dynamic>.from(tempPortsJson)
          .map(
            (e) => EndpointPort.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  return EndpointSubset(
    addresses: tempAddresses,
    notReadyAddresses: tempNotReadyAddresses,
    ports: tempPorts,
  );
}