Hello.
I'm trying to produce a Node-Red chart from SQLite.
I'm stuck on the Jsonata expression and its due to extra layer of "[ ]" with in the payload.
please ref to the image below.
If i remove these "[ ]" the payload is transformed correctly.
Can any advise how to account for this nested data in the jsonata expression.
E1cid
2
Hard to test from a image, best to paste text.
Try $$.payload.*.[{xy object}]
p.s. msg is not required.
Thank that worked.
when I removed the msg. it produces a blank data section, so I've left them in for now
May I ask where I can find that type of formatting for future referencing and any further nesting would need and extra "*."
Text for future reference
{
"series" :$distinct(msg.payload.POINTNAME),
"labels" :["15 Minute"],
"data" : $$.msg.payload.*.[
{
"x": (TIMESTAMP),
"y": (PV) }
]
}
data
{
"topic": "SELECT pointname, timestamp, pv FROM 'HistoryData' WHERE pointname= 'Temp213' AND timestamp >= '1646636665762' AND timestamp <= '1646723065762'",
"_msgid": "338057f6.b75",
"payload": [
[
{
"POINTNAME": "Temp213",
"TIMESTAMP": 1646637088491,
"PV": 32.9
},
{
"POINTNAME": "Temp213",
"TIMESTAMP": 1646722282611,
"PV": 29.9
}
]
]
}
output
{
"series": "Temp213",
"labels": [
"15 Minute"
],
"data": [
[
{
"x": 1646637088491,
"y": 32.9
}
],
[
{
"x": 1646722282611,
"y": 29.9
}
]
]
}
E1cid
4
Strange, i would love to test but i am not going to type all that in.
The jsonata web page docs, is were i get all my info.
[edit]
with data provided the expression would be
{
"series" :[$distinct($$.payload.POINTNAME)],
"labels" :["15 Minute"],
"data" : [
[$$.payload[0].{
"x": $.TIMESTAMP,
"y": $.PV }
]
]
}
* for one level nesting
** for all level nesting
system
Closed
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.