Set the response content type to application/json and serialize
        the content.

        :param anwser The response as a Python object

def json(self, answer):
        """
        Set the response content type to application/json and serialize
        the content.

        :param anwser The response as a Python object
        """

        self.content_type = "application/json"
        if hasattr(answer, '__json__'):
            answer = answer.__json__()
        elif isinstance(answer, list):
            newanswer = []
            for elem in answer:
                if hasattr(elem, '__json__'):
                    elem = elem.__json__()
                newanswer.append(elem)
            answer = newanswer
        if self._output_schema is not None:
            try:
                jsonschema.validate(answer, self._output_schema)
            except jsonschema.ValidationError as e:
                log.error("Invalid output query. JSON schema error: {}".format(e.message))
                raise aiohttp.web.HTTPBadRequest(text="{}".format(e))
        self.body = json.dumps(answer, indent=4, sort_keys=True).encode('utf-8')