Trying to write a function without much success:
How to take a msg objects and sub objects and pass them as top msg.
Example: msg has 3 objects (payload,req,res) and their sub objects.
2 object that generated as part of the http in node [res,req]
single msg.payload contains the following { "color":"red", "size":42 }.
I wish to take the objects from the payload and move them up to the top level where the payload exist beside the res,req. and pass that newly crafted msg to the next node.
I don't think it's going to work as the payload content is dynamic (constantly changing based on the API body that was submitted) and it's not constant color or size, it could be "move":"up" or "temperature":29
If necessary, yes. I did say that my code copied the values. If a move is necessary then they can be deleted from the payload as you suggest. Very likely it is not necessary though.
If you have delete msg.payload then you don't need the delete msg.payload[key]. Are you sure you need to do that though? What is the benefit? If you do not need to do it then you are just adding lines of code and using up processor time for no purpose.