[Solved] How to get ObjectName (Object property) from array


I don't know is it called ObjectName anot, but I am trying to get all of the title.
From this payload I want to get the name of the data"Union ID" "Player" etc and put it in a flow variable:

Welcome to the forum @fangfang94

Why don't you just put the whole object in flow memory, then you can get at any of the properties any time you like?

You can use Object.keys() in a function node Object.keys() - JavaScript | MDN
In a change node $keys() using a JSONata expression Object functions · JSONata

Hi Colin, I am not understating about put the whole object in flow memory

is that I should connect my json -> function -> debug

and inside my function i use the Object.keys method?


[{"id":"45d91520.88ed9c","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"one\":1,\"two\":2},{\"three\":3,\"four\":4}]","payloadType":"json","x":153.00001525878906,"y":4714,"wires":[["49cd18b5.1d00d8"]]},{"id":"49cd18b5.1d00d8","type":"function","z":"b779de97.b1b46","name":"","func":"msg.payload = Object.keys(msg.payload[0]);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":343.00001525878906,"y":4714,"wires":[["a22d044f.37e61"]]},{"id":"a22d044f.37e61","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":713.0000152587891,"y":4714,"wires":[]}]

Thanks bro !!

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