How to add an json object to an array

I have a msg.arrFile array.

I researched then there is a method $append(array1, array2), but returns an array containing the values in array1 followed by the values in array2
https://docs.jsonata.org/array-functions#append

Is there a way to add the json object that is the information of a file to msg.arrFile without using the function node?

Hi @minhhn0205

Can you provide an example of the data you have in msg and what you want the result to look like?

1 Like

Here is a simple example, hope it helps. Notice the
[ ] around the object

[{"id":"187967a.a95e618","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"object","v":"{\"1\":1,\"2\":2}","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3]","payloadType":"json","x":130,"y":500,"wires":[["4119a2a6.a337dc"]]},{"id":"4119a2a6.a337dc","type":"change","z":"4484ee28.caa3c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$append(payload, [object])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":500,"wires":[["269a25ff.79887a"]]},{"id":"269a25ff.79887a","type":"debug","z":"4484ee28.caa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]}]
1 Like

Great, thank you very much for the effort! <3

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