<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_time_event_json(self):
 """Convert a TimeEvent object to json format."""

        time_event = {}
        time_event['time'] = self.timestamp

        if self.annotation is not None:
            time_event['annotation'] = self.annotation.format_annotation_json()

        if self.message_event is not None:
            time_event['message_event'] = \
                self.message_event.format_message_event_json()

        return time_event