# Form two separate Objects from received one object

**URL:** https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830
**Category:** General
**Created:** [23 July 2021 20:14 UTC](https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830 "2021-07-23T20:14:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mafify](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mafify](https://discourse.nodered.org/u/mafify)
#### Post date: [23 July 2021 20:14 UTC](https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830/1 "2021-07-23T20:14:19Z")

</div>

Hello, everyone. I have a question to split one Object that is received as a msg.payload on one of the nodes like the one below

```auto
{Time: "2021-07-23T20:09:33.985Z", Voltage: 12.0, Current: 1.2, S: 1, Su: 0}

```

I want to know if there is a node or a function that can be added to that node to split them in a specific order like this

```auto
{Time: "2021-07-23T20:09:33.985Z", Voltage: 12.0, S: 1}
{Time: "2021-07-23T20:09:33.985Z", Current: 1.2, Su: 0}

```

Thank you guys for your help so far.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [23 July 2021 20:24 UTC](https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830/2 "2021-07-23T20:24:55Z")

</div>

A function node (set to 2 outputs) is probably easiest...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/507790549b1c619068a657cfa72bad48b5f6881f.png)

```auto
const m1 = {
    payload: {
        Time: msg.payload.Time,
        Voltage: msg.payload.Voltage,
        S: msg.payload.S,
    }
}
const m2 = {
    payload: {
        Time: msg.payload.Time,
        Current: msg.payload.Current,
        Su: msg.payload.Su,
    }
}

return [m1, m2];

```

However you can do this with 2 change nodes and JSONata

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9db7a8737199d809c80d0eea55fe5fb20add35c.png)

```auto
[{"id":"905288fad5edf836","type":"change","z":"e78eac1c.8b9cf","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"Time\": payload.Time,\t \"Voltage\": payload.Voltage,\t \"S\": payload.S\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1940,"y":320,"wires":[["97cd287a6bda91ae"]]},{"id":"3a7eb1100423f34a","type":"inject","z":"e78eac1c.8b9cf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Time\":\"2021-07-23T20:09:33.985Z\",\"Voltage\":12,\"Current\":1.2,\"S\":1,\"Su\":0}","payloadType":"json","x":1770,"y":340,"wires":[["905288fad5edf836","ac6d7af029189b8d"]]},{"id":"97cd287a6bda91ae","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":320,"wires":[]},{"id":"ac6d7af029189b8d","type":"change","z":"e78eac1c.8b9cf","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"Time\": payload.Time,\t \"Current\": payload.Current,\t \"Su\": payload.Su\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1940,"y":360,"wires":[["7d33a4c58ac81906"]]},{"id":"7d33a4c58ac81906","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":360,"wires":[]}]

```

Or 2 change nodes and several `delete` entries...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f312b77484646e55586c638a8bee382ffdeeb2a.png)

```auto
[{"id":"905288fad5edf836","type":"change","z":"e78eac1c.8b9cf","name":"delete Current and Su","rules":[{"t":"delete","p":"payload.Current","pt":"msg"},{"t":"delete","p":"payload.Su","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1960,"y":320,"wires":[["97cd287a6bda91ae"]]},{"id":"3a7eb1100423f34a","type":"inject","z":"e78eac1c.8b9cf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Time\":\"2021-07-23T20:09:33.985Z\",\"Voltage\":12,\"Current\":1.2,\"S\":1,\"Su\":0}","payloadType":"json","x":1770,"y":340,"wires":[["905288fad5edf836","e377caf92f7b5c53"]]},{"id":"97cd287a6bda91ae","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":320,"wires":[]},{"id":"7d33a4c58ac81906","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":360,"wires":[]},{"id":"e377caf92f7b5c53","type":"change","z":"e78eac1c.8b9cf","name":"delete Voltage and S","rules":[{"t":"delete","p":"payload.Voltage","pt":"msg"},{"t":"delete","p":"payload.S","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1960,"y":360,"wires":[["7d33a4c58ac81906"]]}]

```

---

<div class="post-metadata">

### Author: ![mafify](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mafify](https://discourse.nodered.org/u/mafify)
#### Post date: [23 July 2021 21:25 UTC](https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830/3 "2021-07-23T21:25:19Z")

</div>

> [@Steve-Mcl](#):
>
> ```auto
> [{"id":"905288fad5edf836","type":"change","z":"e78eac1c.8b9cf","name":"delete Current and Su","rules":[{"t":"delete","p":"payload.Current","pt":"msg"},{"t":"delete","p":"payload.Su","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1960,"y":320,"wires":[["97cd287a6bda91ae"]]},{"id":"3a7eb1100423f34a","type":"inject","z":"e78eac1c.8b9cf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Time\":\"2021-07-23T20:09:33.985Z\",\"Voltage\":12,\"Current\":1.2,\"S\":1,\"Su\":0}","payloadType":"json","x":1770,"y":340,"wires":[["905288fad5edf836","e377caf92f7b5c53"]]},{"id":"97cd287a6bda91ae","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":320,"wires":[]},{"id":"7d33a4c58ac81906","type":"debug","z":"e78eac1c.8b9cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2150,"y":360,"wires":[]},{"id":"e377caf92f7b5c53","type":"change","z":"e78eac1c.8b9cf","name":"delete Voltage and S","rules":[{"t":"delete","p":"payload.Voltage","pt":"msg"},{"t":"delete","p":"payload.S","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1960,"y":360,"wires":[["7d33a4c58ac81906"]]}]
> 
> ```

Amazing, thank you so much for that easy solution

---

<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: [15 September 2021 17:46 UTC](https://discourse.nodered.org/t/form-two-separate-objects-from-received-one-object/48830/4 "2021-09-15T17:46:11Z")

</div>

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