serialize method

String serialize()

Serializes the Request instance into a Nostr message format.

The Nostr message format is a JSON-encoded array with the following structure: "REQ", subscription_id, filter JSON, filter JSON, ...

Implementation

String serialize() {
  final theFilters =
      json.encode(filters.map((item) => item.toJson()).toList());
  final header = json.encode(['REQ', subscriptionId]);
  return '${header.substring(0, header.length - 1)},${theFilters.substring(1, theFilters.length)}';
}