toJson method

Map<String, Object> toJson()

Converts a NetworkPolicyIngressRule instance to JSON data.

Implementation

Map<String, Object> toJson() {
  final jsonData = <String, Object>{};

  final tempFrom = from;
  final tempPorts = ports;

  if (tempFrom != null) {
    jsonData['from'] =
        tempFrom.map((e) => e.toJson()).toList(growable: false);
  }

  if (tempPorts != null) {
    jsonData['ports'] =
        tempPorts.map((e) => e.toJson()).toList(growable: false);
  }

  return jsonData;
}