将两个数组转换为单个对象数组

问题描述

我有两个数组,需要使用 jolt 将这些数组转换为单个对象数组。

输入

"Name": ["Test  Test","Test2  Test"]
"email": ["Test@tesasds.com","Test2@test.com"]

输出

[{"Name":"Test  Test","email":"Test@tesasds.com"},{"Name":"Test2  Test","email":"Test2@test.com"}]

解决方法

内嵌描述:

[
  {
    "operation": "shift","spec": {
      // for every key
      "*": {
        // and every item in the array
        "*": {
          // create a structure <index of array> : key : value
          // This will therefore join the two because the indexes will be the same
          "@": "&.&2"
        }
      }
    }
  },{
    //Remove the index as key
    "operation": "shift","spec": {
      "*": "[]"
    }
  }
]

我建议您先轮班以了解说明。