toJson method
Converts a MetricSpec instance to JSON data.
Implementation
Map<String, Object> toJson() {
final jsonData = <String, Object>{};
final tempContainerResource = containerResource;
final tempExternal = external;
final tempObject = object;
final tempPods = pods;
final tempResource = resource;
final tempType = type;
if (tempContainerResource != null) {
jsonData['containerResource'] = tempContainerResource.toJson();
}
if (tempExternal != null) {
jsonData['external'] = tempExternal.toJson();
}
if (tempObject != null) {
jsonData['object'] = tempObject.toJson();
}
if (tempPods != null) {
jsonData['pods'] = tempPods.toJson();
}
if (tempResource != null) {
jsonData['resource'] = tempResource.toJson();
}
jsonData['type'] = tempType;
return jsonData;
}