JSON expression instead of many change nodes?

Is it possible to use an expression instead of the plethora of change nodes i've created?
I'm running into the problem where I want to filter out the output of the change nodes and it's quite cumbersome with that many nodes.

The change nodes are moving two values from an array in a set pattern.

[{"id":"7e05bfe6.193dd","type":"change","z":"392484c1.36304c","name":"1","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload[0][1]","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[1][1]","tot":"msg"},{"t":"set","p":"payload1","pt":"msg","to":"payload[2][1]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1290,"y":1100,"wires":[["52f74198.0e62d"]]},{"id":"3628255f.ec331a","type":"change","z":"392484c1.36304c","name":"2","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload[0][2]","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[1][2]","tot":"msg"},{"t":"set","p":"payload1","pt":"msg","to":"payload[2][2]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1290,"y":1140,"wires":[["52f74198.0e62d"]]}]

A visual of my flow.

Can you provide some data that is going into the flow?

It's a payload with three arrays.

Screen Shot 2020-08-03 at 1.36.56 PM

[["(20 TOTAL)","robot_name_tv","dashboard_toggle_text","arc","dashboard_start_button_text","tv_menu_text","tv_menu_text","tv_menu_text","tv_menu_text","tv_menu_text","dashboard_toggle","custom_switch_toggle_text_off","dashboard_next_operation_text_top_title2","dashboard_next_operation_text_day2","dashboard_next_operation_text_top_date2","dashboard_next_operation_text_top_time2","dashboard_next_operation_text_top_title","dashboard_next_operation_text_day","dashboard_next_operation_text_top_date","dashboard_next_operation_text_top_time","dashboard_robot_location",{"s":"","orig":"","length":0},{"s":"","orig":"","length":0}],["(20 TOTAL)","RC","SCHEDULE","Mow","Mow","Help Center","Menu","Schedule","History","Manual","Schedule off","OFF","Previous operation","---","--- --","--:--","Next operation","---","--- --","--:--","Connecting"],["(20 TOTAL)","74,154","413,286","540,1128","279,1127","496,1707","243,1772","720,1014","768,1271","687,1519","652,293","692,289","217,403","130,504","276,466","270,523","698,403","648,504","794,466","788,523","870,1880"]]

The change node combines array 0,0; 1,0; 2,0. Then 0,1; 1,1; 2,1. Then 0,2; 1,2; 2,2 and so on.

I notice that payload[0] has 23 items while [1] and [2] have only 20. How do you handle that?

They are just empty. I think I got my problem solved in my other thread by Steve-Mcl.

Great! Just to let you know, your change nodes would not have worked the wScreen Shot 2020-08-03 at 3.56.23 PM ay you had them.

Rule 2 will set msg.payload to the contents of msg.payload[1][1]
Rule 3 wants to set msg.payload1 to the contents of msg.payload[2][1] but msg.payload has been overwritten by the contents of msg.payload[1][1].

To do this you could do something like this:
Screen Shot 2020-08-03 at 4.00.31 PM

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.