def apply(self, callback, _):
        dumps = self.json_dumps
        if not dumps: return callback

        def wrapper(*a, **ka):
            try:
                rv = callback(*a, **ka)
            except __HOLE__:
                rv = _e()

            if isinstance(rv, dict):
                #Attempt to serialize, raises exception on failure
                json_response = dumps(rv)
                #Set content type only if serialization successful
                response.content_type = 'application/json'
                return json_response
            elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict):
                rv.body = dumps(rv.body)
                rv.content_type = 'application/json'
            return rv

        return wrapper
dataset/ETHPy150Open Arelle/Arelle/arelle/webserver/bottle.py/JSONPlugin.apply