# Combine Payloads into an object

**URL:** <https://discourse.nodered.org/t/combine-payloads-into-an-object/24865>\
**Category:** General\
**Created:** [15 April 2020 11:07 UTC](https://discourse.nodered.org/t/combine-payloads-into-an-object/24865 "2020-04-15T11:07:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chaos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chaos/32/107061_2.png) [@Chaos](https://discourse.nodered.org/u/Chaos)\
**Post date:** [15 April 2020 11:07 UTC](https://discourse.nodered.org/t/combine-payloads-into-an-object/24865/1 "2020-04-15T11:07:32Z")

</div>

I am trying to combine two output topic, payload pairs into an object made up of the payloads.  
the two msg's come out of node-red-ramp-thermostat as topic = current / payload = value & topic = target / payload = value  
I have tried using If statement approach on the topics but this seems a complicated / messy way of doing things. Is there a simple way to do this in a function. i need the output object to be msg,value = current payload, msg threshold=target payload.  
maybe there is a node that already does this ? I have tried "join node" but cant get it to work, i would rather use a function if possable.  
Chris

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 April 2020 11:22 UTC](https://discourse.nodered.org/t/combine-payloads-into-an-object/24865/2 "2020-04-15T11:22:29Z")

</div>

> [@Chaos](#):
>
> I have tried "join node" but cant get it to work, i would rather use a function if possable.

From your description, the Join node should be able to do what you want - or at least, it can do the work to get the two separate messages joined into one message. You would then need a Change node to get the different properties into exactly the form you want.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/54455097554def6cd19be802202c1241680a4fae.png)

```auto
[{"id":"2436f695.a2901a","type":"inject","z":"6a4f2112.f1006","name":"","topic":"current","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":1420,"wires":[["cde37530.1fedb8"]]},{"id":"cde37530.1fedb8","type":"join","z":"6a4f2112.f1006","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":460,"y":1440,"wires":[["82d73490.519b88"]]},{"id":"d7a80a7d.245228","type":"inject","z":"6a4f2112.f1006","name":"","topic":"target","payload":"123","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":1480,"wires":[["cde37530.1fedb8"]]},{"id":"1f25dbb9.d46164","type":"debug","z":"6a4f2112.f1006","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":1440,"wires":[]},{"id":"82d73490.519b88","type":"change","z":"6a4f2112.f1006","name":"","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.current","tot":"msg"},{"t":"set","p":"threshold","pt":"msg","to":"payload.target","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1440,"wires":[["1f25dbb9.d46164"]]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 April 2020 11:22 UTC](https://discourse.nodered.org/t/combine-payloads-into-an-object/24865/3 "2020-04-29T11:22:33Z")

</div>

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