code: def returns_json(func):
      
      def decorator(*args, **kwargs):
          instance = args[0]
          request = getattr(instance, 'request', None)
          request.response.setHeader("Content-Type", "application/json")
          result = func(*args, **kwargs)
          return json.dumps(result)
      return decorator
docs: Decorator for functions which return JSON