A function node containing this will merge all previous values with the current values in the payload, if that is what you are looking for
let values = flow.get("values") || {}
Object.assign( values, msg.payload)
flow.set("values", values)
msg.payload = values
return msg;
Example flow:
[{"id":"fc5427b9.f8d0f8","type":"debug","z":"84405ff5.25fa6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":1260,"wires":[]},{"id":"fe1a639c699fc2ec","type":"inject","z":"84405ff5.25fa6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2}","payloadType":"json","x":210,"y":1240,"wires":[["50c9c922cf4da5e7"]]},{"id":"40f54be8c9bda68c","type":"inject","z":"84405ff5.25fa6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"c\": 3}","payloadType":"json","x":190,"y":1300,"wires":[["50c9c922cf4da5e7"]]},{"id":"50c9c922cf4da5e7","type":"function","z":"84405ff5.25fa6","name":"Merge","func":"let values = flow.get(\"values\") || {}\nObject.assign( values, msg.payload)\nflow.set(\"values\", values)\nmsg.payload = values\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":1260,"wires":[["fc5427b9.f8d0f8"]]},{"id":"51904c66d8f80f90","type":"inject","z":"84405ff5.25fa6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"c\": 4}","payloadType":"json","x":190,"y":1360,"wires":[["50c9c922cf4da5e7"]]}]
By the way, it isn't a JSON object, JSON is always a string. It is a javascript object.