toJson method

  1. @protected
Map<String, dynamic> toJson(
  1. {bool full,
  2. bool forApiRQ = false,
  3. bool allowCustomObjectId = false}
)

Converts object to String in JSON format

Implementation

@protected
Map<String, dynamic> toJson({
  bool full,
  bool forApiRQ = false,
  bool allowCustomObjectId = false,
}) {
  final Map<String, dynamic> map = <String, dynamic>{
    keyVarClassName: parseClassName,
  };

  if (objectId != null) {
    map[keyVarObjectId] = objectId;
  }

  if (createdAt != null) {
    map[keyVarCreatedAt] = _parseDateFormat.format(createdAt);
  }

  if (updatedAt != null) {
    map[keyVarUpdatedAt] = _parseDateFormat.format(updatedAt);
  }

  final Map<String, dynamic> target =
      forApiRQ ? _unsavedChanges : _getObjectData();
  target.forEach((String key, dynamic value) {
    if (!map.containsKey(key)) {
      map[key] = parseEncode(value, full: full);
    }
  });

  if (forApiRQ) {
    map.remove(keyVarCreatedAt);
    map.remove(keyVarUpdatedAt);
    map.remove(keyVarClassName);
    //map.remove(keyVarAcl);

    if (!allowCustomObjectId) {
      map.remove(keyVarObjectId);
    }
    map.remove(keyParamSessionToken);
  }

  return map;
}