Jolt 变换 JSON 数组保留其余字段

Jolt transform JSON array keep rest of the fields

如何在 Jolt 变换 JSON 数组中保留其他字段,我尝试使用通配符但最终输出中未添加字段?

这是我使用的示例输入

[
  {
    "foundduring": "D-DC",
    "user_type": "type1",
    "location": "location1"
  },
  {
    "foundduring": "D-DG",
    "user_type": "type2",
    "location": "location2"
  },
  {
    "foundduring": "D-DI",
    "user_type": "type3",
    "location": "location3"
  }
]

我正在使用以下 Jolt 转换并尝试使用通配符:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "foundduring": {
          "D-DC": {
            "#CycleCount": "[&3].foundduring"
          },
          "D-DG": {
            "#Pick": "[&3].foundduring"
          },
          "D-DI": {
            "#Issue": "[&3].foundduring"
          }
        },
        "@": "&"
      }
    }
  }
]

以下是我预期的输出,其中发生了移位操作,然后需要保持所有其他字段不变

[
  {
    "foundduring" : "CycleCount",
    "user_type" : "type1",
    "location" : "location1"
  },
   {
    "foundduring" : "Pick",
    "user_type" : "type2",
    "location" : "location2"
  },
   {
    "foundduring" : "Issue",
    "user_type" : "type3",
    "location" : "location3"
  }
]

即将到来的实际输出:

[
  {
    "foundduring": "CycleCount"
  },
  {
    "foundduring": "Pick"
  },
  {
    "foundduring": "Issue"
  }
]

考虑使用 "*" 通配符作为 else case 而不是 "@" 比如

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "foundduring": {
          "D-DC": {
            "#CycleCount": "[&3].&2"
          },
          "D-DG": {
            "#Pick": "[&3].&2"
          },
          "D-DI": {
            "#Issue": "[&3].&2"
          }
        },
        "*": "[&1].&"
      }
    }
  }
]

顺便说一句,无需获取密钥名称 "foundduring",只需使用 &2 替换即可从当前分支并获取该值。

站点http://jolt-demo.appspot.com/上的演示