NiFi JOLT 转换规范需要将 2 个键合并为 1 个键,并将该值保留为第三个键的值。
该规范没有给出所需的输出。需要震动规格才能获得所需的结果。
输入:
{
"options": [
{
"method": "EMAIL",
"type": “ABCD,
"flag": false,
"updateSource": "I"
},
{
"method": "ALL",
"type": “EFGH”,
"flag": false,
"updateSource": "I"
},
{
"method": "EMAIL",
"type": “QRST,
"flag": true,
"updateSource": "I"
}
]
}
所需输出:
{
“options":
{
"EMAIL_ABCD”: false,
"EMAIL_ABCD_updateSource": "I"
"ALL_EFGH”: false,
"ALL_EFGH_updateSource": "I"
"EMAIL_QRST”: true,
"EMAIL_QRST _updateSource": "I"
}
}
规格:
{
"operation": "shift",
"spec": {
"options": {
"*": {
"method": {
"*": {
"@concat((2,method), '_' ,(2,type))": "@(2,flag)"
}
}
}
},
"*": "&"
}
}
任何函数(在本例中为
concat
)都应该在 modify
规范中使用,
然后匹配 shşft 规范中的返回属性,例如
[
{
"operation": "modify-overwrite-beta",
"spec": {
"options": {
"*": {
"title1": "=concat(@(1,method),'_',@(1,type))",
"title2": "=concat(@(1,title1),'_updateSource')"
}
}
}
},
{
"operation": "shift",
"spec": {
"options": {
"*": {
"@flag": "@title1",
"@updateSource": "@title2"
}
}
}
}
]