toJson method

Map<String, Object> toJson()

Converts a MatchResources instance to JSON data.

Implementation

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

  final tempExcludeResourceRules = excludeResourceRules;
  final tempMatchPolicy = matchPolicy;
  final tempNamespaceSelector = namespaceSelector;
  final tempObjectSelector = objectSelector;
  final tempResourceRules = resourceRules;

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

  if (tempMatchPolicy != null) {
    jsonData['matchPolicy'] = tempMatchPolicy;
  }

  if (tempNamespaceSelector != null) {
    jsonData['namespaceSelector'] = tempNamespaceSelector.toJson();
  }

  if (tempObjectSelector != null) {
    jsonData['objectSelector'] = tempObjectSelector.toJson();
  }

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

  return jsonData;
}