code: function workaroundAwsObjectSerialization(data) {
    var returnEmptyObject = function() { return "{}"; };
  
    // This never be called because keySet/entrySet/size will be processed by velocity.js.
    // But I want to handling only toString
    var builtinMethod = function() { throw "unexpected error"; };
    builtinMethod.toString = returnEmptyObject;
  
    data.input.toString = returnEmptyObject;
    data.util.toString = returnEmptyObject;
    walk(data, function(obj) {
      if (typeof(obj) == 'function') {
        obj.toString = returnEmptyObject;
      }
  
      obj.keySet = builtinMethod;
      obj.entrySet = builtinMethod;
      obj.size = builtinMethod;
    });
  
    return data;
  }
docs: Workaround to followings When the tempalte is "$input.params" (is a Function) - AWS API Gateway returns "{}". - This is not org.apache.velocity's behaviour. It returns "$input.params". When the tempalte is "$input" or "$util" - AWS API Gateway returns "{}" - This is not org.apache.velocity's behaviour. It returns serialized hash.