Converts this pattern to a JSON-compatible map.
Map<String, dynamic> toJson() { return { 'Pattern': events.map((e) => e.toJson()).toList(), }; }