Support Questions

Find answers, ask questions, and share your expertise

How does nIFi implement JSON parsing and merging

avatar

mqtt -> flattenjosn -> spiltjson -> evajsonpath

Data received by MQTT:

{"device_name":"Device37","device_id":"GanghuaLianXian","date":"2021-09-24 17:45:44","sensor":[{"sensor_id":"Data05_37_alarm","value ":"0"},{"sensor_id":"Data06_37_alarm","value":"0"},{"sensor_id":"Data07_37_alarm","value":"0"},
],"status":1 }

Parsing json:  

"sensor":[{"sensor_id":"Data05_37_alarm","value":"0"},{"sensor_id":"Data06_37_alarm","value":"0"},{"sensor_id":"Data07_37_alarm", "值":"0"},
],

Merge the json:

{"device_name":"Device37","device_id":"GangHuaLianXian","date":"2021-09-24 17:45:44","sensor_id":"Data05_37_alarm","value":"0"} ,

{"device_name":"Device37","device_id":"GangHuaLianXian","date":"2021-09-24 17:45:44","sensor_id":"Data06_37_alarm","value":"0"} ,

{"device_name":"Device37","device_id":"GangHuaLianXian","date":"2021-09-24 17:45:44","sensor_id":"Data07_37_alarm","value":"0"} ,

How to achieve?

1 REPLY 1

avatar

cn-programmer_2-1632820930922.png

我是这样做的.

EvaluateJsonPath

cn-programmer_3-1632820968842.png

SplitJson

cn-programmer_4-1632820983287.png

ExtractText

cn-programmer_5-1632821008967.png

ReplaceText

cn-programmer_6-1632821033635.png

就是不知道怎么把splitjson里面的数据用ReplaceText合并.

cn-programmer_7-1632821095255.png