code: def to_json(self):
          
          event_as_dict = copy.deepcopy(self.event_body)
          if self.timestamp:
              if "keen" in event_as_dict:
                  event_as_dict["keen"]["timestamp"] = self.timestamp.isoformat()
              else:
                  event_as_dict["keen"] = {"timestamp": self.timestamp.isoformat()}
          return json.dumps(event_as_dict)
docs: Serializes the event to JSON.
  
          :returns: a string