toJson method

Map<String, Object> toJson()

Converts a NetworkPolicyPort instance to JSON data.

Implementation

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

  final tempEndPort = endPort;
  final tempPort = port;
  final tempProtocol = protocol;

  if (tempEndPort != null) {
    jsonData['endPort'] = tempEndPort;
  }

  if (tempPort != null) {
    jsonData['port'] = tempPort;
  }

  if (tempProtocol != null) {
    jsonData['protocol'] = tempProtocol;
  }

  return jsonData;
}