Serializes the ``Task`` data for storing in the queue.

        All data must be JSON-serializable in order to be stored properly.

        :returns: A JSON strong of the task data.

def serialize(self):
        """
        Serializes the ``Task`` data for storing in the queue.

        All data must be JSON-serializable in order to be stored properly.

        :returns: A JSON strong of the task data.
        """
        data = {
            'task_id': self.task_id,
            'retries': self.retries,
            'async': self.async,
            'module': determine_module(self.func),
            'callable': determine_name(self.func),
            'args': self.func_args,
            'kwargs': self.func_kwargs,
            'options': {},
        }

        if self.on_start:
            data['options']['on_start'] = {
                'module': determine_module(self.on_start),
                'callable': determine_name(self.on_start),
            }

        if self.on_success:
            data['options']['on_success'] = {
                'module': determine_module(self.on_success),
                'callable': determine_name(self.on_success),
            }

        if self.on_error:
            data['options']['on_error'] = {
                'module': determine_module(self.on_error),
                'callable': determine_name(self.on_error),
            }

        return json.dumps(data)