In a change node
set msg.
payload
to JSONata J:
{
"today": [
$$.payload[[1..$count($$.payload)]].{ "value": $.price, "start": $.timestamp }
]
}
Assuming value is price, and the first element is always the previous day.
Or if value is the index
{
"today": [
$$.payload#$i.{ "value": $i, "start": timestamp }[[1..$count($$.payload)]]
]
}
Or low code version
[{"id":"3ad52acd055ad880","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"timestamp\":\"2023-02-25T23:00:00.000Z\",\"price\":356.8,\"currency\":\"SEK\",\"area\":\"SE4\"},{\"timestamp\":\"2023-02-26T00:00:00.000Z\",\"price\":370.04,\"currency\":\"SEK\",\"area\":\"SE4\"},{\"timestamp\":\"2023-02-26T01:00:00.000Z\",\"price\":387.15,\"currency\":\"SEK\",\"area\":\"SE4\"},{\"timestamp\":\"2023-02-26T02:00:00.000Z\",\"price\":391.67,\"currency\":\"SEK\",\"area\":\"SE4\"}]","payloadType":"json","x":130,"y":880,"wires":[["971e2dba4ee00636"]]},{"id":"971e2dba4ee00636","type":"split","z":"65617ffeb779f51c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":250,"y":880,"wires":[["ba926d9c6ca51768"]]},{"id":"ba926d9c6ca51768","type":"template","z":"65617ffeb779f51c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"start\":\"{{payload.timestamp}}\",\"value\":{{parts.index}}}","output":"json","x":400,"y":880,"wires":[["f0e8bd54dbcc3781"]]},{"id":"f0e8bd54dbcc3781","type":"join","z":"65617ffeb779f51c","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":880,"wires":[["86efa7abf8458994"]]},{"id":"86efa7abf8458994","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"delete","p":"payload[0]","pt":"msg"},{"t":"move","p":"payload","pt":"msg","to":"payload.today","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":880,"wires":[["c1b0021ca796317f"]]},{"id":"c1b0021ca796317f","type":"debug","z":"65617ffeb779f51c","name":"Payload Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":626,"y":688,"wires":[]}]