toJson method
Converts object to String in JSON format
Implementation
Map<String, dynamic> toJson({
bool full = false,
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 target = forApiRQ ? _unsavedChanges : _getObjectData();
target.forEach((String key, dynamic value) {
if (!map.containsKey(key)) {
map[key] = parseEncode(value, full: full);
}
if (forApiRQ &&
value is _ParseRelation &&
!value.shouldIncludeInRequest()) {
map.remove(key);
}
});
if (forApiRQ) {
map.remove(keyVarCreatedAt);
map.remove(keyVarUpdatedAt);
map.remove(keyVarClassName);
//map.remove(keyVarAcl);
if (!allowCustomObjectId) {
map.remove(keyVarObjectId);
}
map.remove(keyParamSessionToken);
}
return map;
}