gpt4 book ai didi

apache-nifi - Nifi中修改JSON键值对

转载 作者:行者123 更新时间:2023-12-04 10:32:33 35 4
gpt4 key购买 nike

我有传入的 JSON 数据行,例如,

{"signalName": "IU_BATT_ParkAssist", "msgId": 2268, "epoch": 1582322746, "usec": 376360, "vlan": "-1", "msgName": "EBS_Frame12", "vin": "000004", "value": 14.171869, "timestamp": 1582322746376}

我希望修改输出以产生,
{"IU_BATT_ParkAssist":14.171869, "msgId": 2268, "epoch": 1582322746, "usec": 376360, "vlan": "-1", "msgName": "EBS_Frame12", "vin": "000004", "timestamp": 1582322746376}

signalName 和 value 键组合成一个新的 键:值对 键是信号名称,值是值字段, "IU_BATT_ParkAssist":14.171869 连同其他原始键值对。

鉴于 signalName 字段将在每一行中动态变化,我如何在 Nifi 中实现这一点?

最佳答案

Try with below spec:

[
{
"operation": "shift",
"spec": {
"@(1,value)": "@(2,signalName)",
"*": "&"
}
},
{
"operation": "remove",
"spec": {
"signalName": "",
"value": ""
}
}
]

换类我们正在合并的操作 signalName and value .

删除 我们正在删除的操作 signalName and value 来自我们的 json数据。

Output:
{
"IU_BATT_ParkAssist" : 14.171869,
"msgId" : 2268,
"epoch" : 1582322746,
"usec" : 376360,
"vlan" : "-1",
"msgName" : "EBS_Frame12",
"vin" : "000004",
"timestamp" : 1582322746376
}

关于apache-nifi - Nifi中修改JSON键值对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60349637/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com