json 如何使用Jolt规范实现所需的输出- Apache NiFi

k10s72fa  于 4个月前  发布在  Apache
关注(0)|答案(1)|浏览(71)

输入:

[ 
  {
    "ImageId" : [ "ami-06a13556596424b", "ami-04d29b6f966df15" ],
    "InstanceId" : [ "i-0b456d23d0a5e44", "i-072b95b1d6a4b11" ],
    "InstanceType" : [ "t2.micro", "t2.micro" ]
  } 
]

字符串
所需输出:

[
  {
    "ImageId": "ami-06a13556594b01",
    "InstanceId": "i-0b456d23d0a5e3",
    "InstanceType": "t2.micro"
  },
  {
    "ImageId": "ami-04d29b6f966df37",
    "InstanceId": "i-072b95b1d6a436",
    "InstanceType": "t2.micro"
  }
]

6mw9ycah

6mw9ycah1#

你可以使用下面的移位变换规范:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": { 
          "*": { // the indexes of the respective arrays
            "@": "[&].&2"
          }
        }
      }
    }
  }
]

字符串
哪里

*&2分别复制数组的键
***[&]**通过数组的索引分隔对象,以数组方式整体返回

网站https://jolt-demo.appspot.com/上的 * 演示 * 是:


的数据

相关问题