toJson method
Converts this comment to a JSON map.
Only includes fields that should be sent to the server. Excludes computed properties like initials and UI-only properties.
Returns a map with the following fields:
id: StringparentId: String? (only if not null)content: StringentityId: StringuserId: Stringusername: String
Note: date, likeCount, and replyCount are excluded as they
are typically managed by the server.
Implementation
Map<String, String> toJson() {
return {
'id': id,
//'date': date.toIso8601String(),
if (parentId != null) 'parentId': parentId!,
'content': content,
'entityId': entityId,
'userId': userId,
'username': username,
//'likeCount': likeCount,
//'replyCount': replyCount,
};
}