【发布时间】:2021-11-23 15:39:23
【问题描述】:
我需要 Jolt 变换方面的帮助。 我有数组,它由许多 json 对象组成。 (https://jolt-demo.appspot.com/)
[
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 1
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 34
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_2",
"scratch_order": 3
}
]
需要对 Jolt 进行什么变换才能得到以下结果?
{
"table_name" : "table_vd",
"data" : [ {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 1
}, {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 34
}, {
"scratch_name" : "l1_sample_2",
"scratch_order" : 3
} ]
}
现在我有了下一个 Jolt 构造:
[
{
"operation": "shift",
"spec": {
"*": {
"table_name": "table_name",
"*": {
"@0": "data[0].&1"
}
}
}
}
]
但是下面的结果是不正确的:
{
"table_name" : [ "table_vd", "table_vd", "table_vd" ],
"data" : [ {
"scratch_name" : [ "l1_sample_1_1", "l1_sample_1_1", "l1_sample_2" ],
"scratch_order" : [ 1, 34, 3 ]
} ]
}
【问题讨论】:
-
请张贴您到目前为止所做的代码,并将代码从图像中删除到文本中。
标签: json apache-nifi jolt