需要使用 JOLT 变换将 JSON 变换为特定的 JSON

Need to Transform JSON using JOLT transformation to specific JSON

我有以下用户输入 json。 [ { “correlationId”:“12345”, "payloadFormat": "金钱", “有效载荷”:{ "DE61": "000001000150084063368", “位置”:“南”, "name": "达拉斯", “流行”:“2M” } }, { “correlationId”:“ed1e3”, "payloadFormat": "现金", “有效载荷”:{ "DE": "000001000150084063368", “位置”:“西”, "name": "洛杉矶", “流行”:“4M” } } ]

我需要在 JOLT 规范的帮助下转换为以下输出

[ { “correlationId”:“12345”, "payloadFormat": "金钱", "DE61SF1": "00", "DE61SF2": "100015008", "DE61SF3": "4063368", “位置”:“南”, "name": "达拉斯", “流行”:“2M” }, { “correlationId”:“ed1e3”, "payloadFormat": "现金", "DE61SF1": "00", "DE61SF2": "100015008", "DE61SF3": "4063368", “位置”:“西”, "name": "洛杉矶", “流行”:“4M” } ]

检查此规范,

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "@": "&",
        // Shift all the DE nodes to a same named node.
        // Here it is moved as TMPDE
        "payload": {
          "DE|DE61": "&2.payload.TMPDE"
        }
      }
    }
  }, {
    "operation": "modify-default-beta",
    "spec": {
      "*": {
        "payload": {
          "DE61SF1": "=substring(@(1,TMPDE), 2, 4)",
          "DE61SF2": "=substring(@(1,TMPDE), 5, 14)",
          "DE61SF3": "=substring(@(1,TMPDE), 14, 21)"
        }
      }
    }
  }, {
    "operation": "shift",
    "spec": {
      "*": {
        "correlationId": "[&1].correlationId",
        "payloadFormat": "[&1].payloadFormat",
        "payload": {
          "DE61SF1": "[&2].DE61SF1",
          "DE61SF2": "[&2].DE61SF2",
          "DE61SF3": "[&2].DE61SF3",
          "location": "[&2].location",
          "pop": "[&2].pop",
          "name": "[&2].name"
        }
      }
    }
  }
]