toJson method

Map<String, Object> toJson()

Converts a HostAlias instance to JSON data.

Implementation

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

  final tempHostnames = hostnames;
  final tempIp = ip;

  if (tempHostnames != null) {
    jsonData['hostnames'] = tempHostnames;
  }

  if (tempIp != null) {
    jsonData['ip'] = tempIp;
  }

  return jsonData;
}