我正在写jolt来转换这些数据,但是没有得到想要的结果
如果practice_loc
、prac_num
和topId
对于两个或多个数据是相同的,则它们将与subList
内的单独的S1和S2组合在一起。否则,它们将通过,因为它是只添加子列表。
数据
[
{
"practice_loc": "120",
"prac_num": "oswal",
"topId": "t1",
"S1": "A1",
"S2": "B1"
},
{
"practice_loc": "120",
"prac_num": "oswal",
"topId": "t1",
"S1": "A2",
"S2": ""
},
{
"practice_loc": "334",
"prac_num": "L3",
"topId": "plumcherry",
"S1": "A3",
"S2": ""
},
{
"practice_loc": "987",
"prac_num": "L3",
"topId": "artica",
"S1": "A5",
"S2": "B7"
}
]
预期输出:
[
{
"practice_loc": "120",
"prac_num": "oswal",
"topId": "t1"
"subList": [
{
"S1": "A1",
"S2": "B1"
},
{
"S1": "A2",
"S2": ""
}
]
},
{
"practice_loc": "334",
"prac_num": "L3",
"topId": "plumcherry"
"subList": [
{
"SubID1": "A3",
"SubID2": ""
}
]
},
{
"practice_loc": "987",
"prac_num": "L3",
"topId": "artica",
"subList": [
{
"SubID1": "A5",
"SubID2": "B7"
}
]
}
]
这是我尝试过的,但没有得到预期的结果,它不打印任何东西
[
{
"operation": "shift",
"spec": {
"*": {
"@": "@(1,practice_loc).@(1,prac_num).@(1,topId)"
}
}
},
{
"operation": "cardinality",
"spec": {
"*": {
"*": "MANY"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"practice_loc": "[#4].&",
"prac_num": "[#4].&",
"topId": "[#4].&",
"S*": "[#4].subList[&1].&"
}
}
}
}
},
{
"operation": "cardinality",
"spec": {
"*": {
"practice_loc": "ONE",
"prac_num": "ONE",
"topId": "ONE"
}
}
}
]
1条答案
按热度按时间wn9m85ua1#
你现在的技术水平相当不错。会适合这样重新排列
编辑*用于说明 *:下面,我已经粘贴了图像,我在切换
Configure
部分的ADVANCED
选项卡后得到了JoltTransformJSON
处理器的版本1.21.0作为NiFi。顺便说一句,你的也是最近的版本。