toJson method

Map<String, Object> toJson()

Converts a LabelSelector instance to JSON data.

Implementation

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

  final tempMatchExpressions = matchExpressions;
  final tempMatchLabels = matchLabels;

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

  if (tempMatchLabels != null) {
    jsonData['matchLabels'] = tempMatchLabels;
  }

  return jsonData;
}