Created 03-09-2022 12:48 AM
未处理的表格:
{
"日期":"2022-09-03 19:23:53",
“设备名称”:“032-013”,
"device_id":"1144",
“传感器”:[
{
"sensor_id":"5836",
“价值”:“1”,
“传感器名称”:“设备状态”
},
{
"sensor_id":"5842",
“价值”:””,
“传感器名称”:“12345”
}
…
],
“状态”:“1”
}
最后结果:
{
“日期” :“2022-09-03 19:23:53” ,
“设备名称” :“032-013” ,
“device_id” :“1144” ,
“sensor_id” :“5836” ,
“价值” :“1” ,
“传感器名称” :“设备状态” ,
“状态” :“1”
}
{
“日期” :“2022-09-03 19:23:53” ,
“设备名称” :“032-013” ,
“device_id” :“1144” ,
“sensor_id” :“58 42 ” ,
“价值” :“1” ,
“传感器名称” :“ 12345 ” ,
“状态” :“1”
}
我已经使用 splitjson 将传感器环出,Device_id 和 device_name 也可以通过 EvaluateJsonPath 获得。
但是现在我不知道如何聚合来自两个处理器的数据?
Created 03-09-2022 03:03 AM
@m_hsn ,
You can use the JoltTransformJSON processor to flatten this JSON structure, using the following JOLT specification:
[
{
"operation": "shift",
"spec": {
"sensor": {
"*": {
"*": "[&1].&",
"@(2,date)": "[&1].date",
"@(2,device_name)": "[&1].device_name",
"@(2,device_id)": "[&1].device_id",
"@(2,status)": "[&1].status"
}
}
}
}
]
Cheers,
André
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Created 03-09-2022 03:03 AM
@m_hsn ,
You can use the JoltTransformJSON processor to flatten this JSON structure, using the following JOLT specification:
[
{
"operation": "shift",
"spec": {
"sensor": {
"*": {
"*": "[&1].&",
"@(2,date)": "[&1].date",
"@(2,device_name)": "[&1].device_name",
"@(2,device_id)": "[&1].device_id",
"@(2,status)": "[&1].status"
}
}
}
}
]
Cheers,
André
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Created 03-09-2022 05:58 PM
thanks a lot