<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, obj):
 """ Print object on output """

        accept = self.request.headers.get("Accept")
        if "json" in accept:
            if JsonDefaultHandler.__parser is None:
                JsonDefaultHandler.__parser = Parser()
            super(JsonDefaultHandler, self).write(JsonDefaultHandler.__parser.encode(obj))
            return
        # If we are not in json mode
        super(JsonDefaultHandler, self).write(obj)