SOURCE

// Read input FlowFile content
var inputText = [{
    "Employee_ID": 100163,
    "Annual_Leave_balance": 18.7499,
    "Payroll_Month": 202203
}, {
    "Employee_ID": 100182,
    "Annual_Leave_balance": 17.7495,
    "Payroll_Month": 202203
}, {
    "Employee_ID": 100464,
    "Annual_Leave_balance": 16.2483,
    "Payroll_Month": 202203
}, {
    "Employee_ID": 100473,
    "Annual_Leave_balance": 17.2483,
    "Payroll_Month": 202203
}, {
    "Employee_ID": 100493,
    "Annual_Leave_balance": 18.9999,
    "Payroll_Month": 202203
}]
var outputObj = [];

// var jsonObj = JSON.parse(inputText);
//var dataArray = jsonObj.data;
var map = {};
for (var i = 0; i < inputText.length; i++) {
    
    var data = inputText[i];
    var dateKey = data["Payroll_Month"]+"01";
   var year = dateKey.substring(0, 4);
   var month = dateKey.substring(4, 6);
   var day =dateKey.substring(6,8);
   var timer = year + "-" + month + "-" + day;
    //var dateKey1=new Date(dateKey).Fo6rmat("yyyy-MM-dd")
  
//var pattern = /(\d{4})(\d{2})/;
//var formatedDate = dateKey.replace(pattern, '$1-$2');
    //var r=dateKey.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3")
  var tmp = {
        "c1": data["Employee_ID"].toString()+data["Payroll_Month"].toString(),
        "c2": data["Employee_ID"].toString(),
        "c4": timer,
        "c3": data["Annual_Leave_balance"]
    };
    outputObj.push(tmp);
} 
      
		function formatDate(date) {
            date = new Date(Date.parse(date.replace(/-/g, "/"))); //转换成Data();
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            m = m < 10 ? '0' + m : m;
            var d = date.getDate();
            d = d < 10 ? ('0' + d) : d;
            return y + '-' + m + '-' + d;
        }

     

map = {
    "rows": outputObj,
    "table_code": "Annual_Leave_Balance"
}

console.log(map)


console 命令行工具 X clear

                    
>
console