How to change an object to array

Hello, we are working on a project. We get some difficulties in it. We try to change our object to array so we can but it to our ui-table. but our function is not working because there is an error call "Circular". we are the beginner of C++ and java so we have no idea to solve this problem.
Any help would be appreciated!!!!!!!!
flows.json (5.7 KB)

The function node uses Javascript, not C++ or Java
here is an example of what i think you are attempting.

[{"id":"8b6c6dab492de80c","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"percy","payloadType":"str","x":90,"y":780,"wires":[["33d14434fec58cba"]]},{"id":"33d14434fec58cba","type":"function","z":"452103ea51141731","name":"name","func":"msg.topic=\"name\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":780,"wires":[["6460ccd0c12d47cd"]]},{"id":"6460ccd0c12d47cd","type":"function","z":"452103ea51141731","name":"Wait for all tasks to finish (object)","func":"let context_data = context.get(\"data\") || {};\n\nswitch (msg.topic) {\n    case \"name\":\n        context_data.name = msg.payload;\n        break;\n    case \"age\":\n        context_data.age = msg.payload;\n        break;\n\n    default:\n        msg = null;\n        break;\n\n}\ncontext.set(\"data\", context_data);\n\nif (context_data.name != null && context_data.age != null ) {\n    msg.payload = [context_data];\n    context.set(\"data\", undefined);\n    \n} else {\n    msg = null;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":840,"wires":[["82b7d693d950ae36","90efc1152e820683"]]},{"id":"129e7260c1d0e982","type":"function","z":"452103ea51141731","name":"age","func":"msg.topic = \"age\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":920,"wires":[["6460ccd0c12d47cd"]]},{"id":"82b7d693d950ae36","type":"json","z":"452103ea51141731","name":"","property":"payload","action":"","pretty":false,"x":570,"y":860,"wires":[["82b00bba414693f7"]]},{"id":"90efc1152e820683","type":"debug","z":"452103ea51141731","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":780,"wires":[]},{"id":"606186d4a55815b7","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12","payloadType":"str","x":90,"y":920,"wires":[["129e7260c1d0e982"]]},{"id":"82b00bba414693f7","type":"debug","z":"452103ea51141731","name":"debug 13","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":720,"y":860,"wires":[]}]

This could also be done with a join node and a change node with out context, and no need for any coding.
e.g.

[{"id":"8b6c6dab492de80c","type":"inject","z":"dd25585074ececfb","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"percy","payloadType":"str","x":190,"y":180,"wires":[["33d14434fec58cba"]]},{"id":"33d14434fec58cba","type":"function","z":"dd25585074ececfb","name":"name","func":"msg.topic=\"name\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":180,"wires":[["d924560092f6cec6"]]},{"id":"d924560092f6cec6","type":"join","z":"dd25585074ececfb","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":240,"wires":[["9186a0a98976be9b"]]},{"id":"129e7260c1d0e982","type":"function","z":"dd25585074ececfb","name":"age","func":"msg.topic = \"age\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":320,"wires":[["d924560092f6cec6"]]},{"id":"9186a0a98976be9b","type":"change","z":"dd25585074ececfb","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":220,"wires":[["82b7d693d950ae36","90efc1152e820683"]]},{"id":"606186d4a55815b7","type":"inject","z":"dd25585074ececfb","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12","payloadType":"str","x":190,"y":320,"wires":[["129e7260c1d0e982"]]},{"id":"82b7d693d950ae36","type":"json","z":"dd25585074ececfb","name":"","property":"payload","action":"","pretty":false,"x":670,"y":260,"wires":[["82b00bba414693f7"]]},{"id":"90efc1152e820683","type":"debug","z":"dd25585074ececfb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":180,"wires":[]},{"id":"82b00bba414693f7","type":"debug","z":"dd25585074ececfb","name":"debug 13","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":260,"wires":[]}]

Thank you I will try it later

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