需要将 Mule3 代码转换为 Mule4 代码的输入

Need inputs to convert Mule3 code to Mule4 code

我们正在将 Mule3 项目迁移到 Mule4。使用 MMA 迁移并遇到很少的转换: 需要将以下 Mule3 代码转换为 Mule4 代码:

#[payload.replace("MonthlyData", tempMonthlyData)]

有效负载=

{
    "MonthlyData": [
    {
      "Directory title": "Test1",
      "P2 - Number": "1234",
      "M1 - Reference Number": "1234049",
      "A5 - Unique Reference Code": "456767",
      "M2 - Valuation Year": "2018"
    },
    {
      "Directory title": "Test1",
      "P2 - Number": "1234",
      "M1 - Reference Number": "123564049",
      "A5 - Unique Reference Code": "45677787",
      "M2 - Valuation Year": "2019"
    }
    ]
}

变量 tempMonthlyData =

[ 
    {
        "Directory title": "Mule3",
        "P2 - Number": "fas62",
        "M1 - Reference Number": "27as0049",
        "A5 - Unique Reference Code": "1as7",
        "M2 - Year": "2016",
        "M4 - Valuer Name ": "asd"
    },
   {
        "Directory title": "Mule4",
        "P2 - Number": "fas62",
        "M1 - Reference Number": "28as0049",
        "A5 - Unique Reference Code": "7as7",
        "M2 - Year": "2018",
        "M4 - Valuer Name ": "xyz"
   }
 ] 

使用更新运算符:

%dw 2.0
output application/json
---
payload  update {
        case .MonthlyData ->  vars.tempMonthlyData
}

输出:

{
  "MonthlyData": [
    {
      "Directory title": "Mule3",
      "P2 - Number": "fas62",
      "M1 - Reference Number": "27as0049",
      "A5 - Unique Reference Code": "1as7",
      "M2 - Year": "2016",
      "M4 - Valuer Name ": "asd"
    },
    {
      "Directory title": "Mule4",
      "P2 - Number": "fas62",
      "M1 - Reference Number": "28as0049",
      "A5 - Unique Reference Code": "7as7",
      "M2 - Year": "2018",
      "M4 - Valuer Name ": "xyz"
    }
  ]
}