Serializes this entry.
Map<String, Object?> toJson() { return <String, Object?>{ 'type': type, if (payload.isNotEmpty) 'payload': payload, }; }