这是我的输入和基于一个文件名路径,我们将对其进行分组并将这些相应的文件添加到每个组的单个数组中。
[ {
"filename" : "FF/raw/first/raw_A/filenameA_20240212002113.DAT"
}, {
"filename" : "FF/raw/first/raw_A/filenameA__20240205150101.DAT"
}, {
"filename" : "FF/raw/first/raw_B/filenameB_20240212002113.DAT"
}, {
"filename" : "FF/raw/first/raw_B/filenameB_20240205150101.DAT"
} ]
and output is required in below format:
[ {
"raw_A":
[
"filenameA_20240212002113.DAT",
"filenameA_20240205150101.DAT"
]
},
{
"raw_B":
[
"filenameB_20240212002113.DAT",
"filenameB_20240205150101.DAT"
]
}
]
您可以使用以下 shift 转换规范:
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*/*/*/*/*": "&(0,4).&(0,5)" // extract the leaf node by using 5th asterisk, eg. use &(0,5)
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"$": "[#2].&2.[#2]"
}
}
}
}
]