Jolt拆分成多个json

x0fgdtte  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(123)

请帮我用jolt转换一下:

预期输入

{
  "sourceNode" : [ "id:source-abc", "id:source-def" ],
  "targetNode" : [ "id:target-abc", "id:target-def"  ]
}

字符串
其中我可能有多个源节点和相同数量的目标节点。我只需要把它拆分成多个JSON。

预期输出

{
  "sourceNode" : "id:source-abc",
  "targetNode" : "id:target-abc"
}
{
  "sourceNode" : "id:source-def",
  "targetNode" : "id:target-def"
}

ma8fv8wu

ma8fv8wu1#

您可以使用以下转换

[
  {
    "operation": "shift",
    "spec": {
      "*": { // the level of the both array
        "*": { // the indexes of the array
          "@": "[#2].&2" // &2 means going 2 levels up to grab the literals "sourceNode" and "targetNode"
                         // [#2] means traversing : and the first { to reach the level of the indexes
                         //            to generate arraywise results           
        }
      }
    }
  }
]

字符串
网站http://jolt-demo.appspot.com/上的 * 演示 * 是:


的数据

相关问题