toJson method

Object toJson()

Converts this object to JSON.

Implementation

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

  void addIfNonNull(String fieldName, Object? value) {
    if (value != null) {
      updateMap[fieldName] = value;
    }
  }

  addIfNonNull('${objectName}sToAdd', serializeMapsObjectSet(_objectsToAdd));
  addIfNonNull(
      '${objectName}sToChange', serializeMapsObjectSet(_objectsToChange));
  addIfNonNull(
      '${objectName}IdsToRemove',
      _objectIdsToRemove
          .map<String>((MapsObjectId<T> m) => m.value)
          .toList());

  return updateMap;
}