toJson method
Converts a EndpointSlice instance to JSON data.
Implementation
Map<String, Object> toJson() {
final jsonData = <String, Object>{};
final tempAddressType = addressType;
final tempApiVersion = apiVersion;
final tempEndpoints = endpoints;
final tempKind = kind;
final tempMetadata = metadata;
final tempPorts = ports;
jsonData['addressType'] = tempAddressType;
if (tempApiVersion != null) {
jsonData['apiVersion'] = tempApiVersion;
}
jsonData['endpoints'] =
tempEndpoints.map((e) => e.toJson()).toList(growable: false);
if (tempKind != null) {
jsonData['kind'] = tempKind;
}
if (tempMetadata != null) {
jsonData['metadata'] = tempMetadata.toJson();
}
if (tempPorts != null) {
jsonData['ports'] =
tempPorts.map((e) => e.toJson()).toList(growable: false);
}
return jsonData;
}