toJson method

Map<String, Object> toJson()

Converts a ObjectMeta instance to JSON data.

Implementation

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

  final tempAnnotations = annotations;
  final tempCreationTimestamp = creationTimestamp;
  final tempDeletionGracePeriodSeconds = deletionGracePeriodSeconds;
  final tempDeletionTimestamp = deletionTimestamp;
  final tempFinalizers = finalizers;
  final tempGenerateName = generateName;
  final tempGeneration = generation;
  final tempLabels = labels;
  final tempManagedFields = managedFields;
  final tempName = name;
  final tempNamespace = namespace;
  final tempOwnerReferences = ownerReferences;
  final tempResourceVersion = resourceVersion;
  final tempSelfLink = selfLink;
  final tempUid = uid;

  if (tempAnnotations != null) {
    jsonData['annotations'] = tempAnnotations;
  }

  if (tempCreationTimestamp != null) {
    jsonData['creationTimestamp'] = tempCreationTimestamp;
  }

  if (tempDeletionGracePeriodSeconds != null) {
    jsonData['deletionGracePeriodSeconds'] = tempDeletionGracePeriodSeconds;
  }

  if (tempDeletionTimestamp != null) {
    jsonData['deletionTimestamp'] = tempDeletionTimestamp;
  }

  if (tempFinalizers != null) {
    jsonData['finalizers'] = tempFinalizers;
  }

  if (tempGenerateName != null) {
    jsonData['generateName'] = tempGenerateName;
  }

  if (tempGeneration != null) {
    jsonData['generation'] = tempGeneration;
  }

  if (tempLabels != null) {
    jsonData['labels'] = tempLabels;
  }

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

  if (tempName != null) {
    jsonData['name'] = tempName;
  }

  if (tempNamespace != null) {
    jsonData['namespace'] = tempNamespace;
  }

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

  if (tempResourceVersion != null) {
    jsonData['resourceVersion'] = tempResourceVersion;
  }

  if (tempSelfLink != null) {
    jsonData['selfLink'] = tempSelfLink;
  }

  if (tempUid != null) {
    jsonData['uid'] = tempUid;
  }

  return jsonData;
}