# Change node change payload from array to number

**URL:** <https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075>\
**Category:** General\
**Created:** [30 January 2021 22:05 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075 "2021-01-30T22:05:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaughan.mcd](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@vaughan.mcd](https://discourse.nodered.org/u/vaughan.mcd)\
**Post date:** [30 January 2021 22:05 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075/1 "2021-01-30T22:05:36Z")

</div>

How to change message from

1/31/2021, 11:01:26 AM[node: 1afb97a5.247c08](http://192.168.20.9:1880/#)polling : msg.payload : array[8]

[false, false, false, false, false, false, false, false]  
To 0

and

1/31/2021, 11:01:26 AM[node: 1afb97a5.247c08](http://192.168.20.9:1880/#)polling : msg.payload : array[8]

[true, false, false, false, false, false, false, false]  
To 1

I tried several but no success ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd6c7d311c8a2820f4d9a7d31f3a4c490b044004.png)

---

<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:** [31 January 2021 00:11 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075/2 "2021-01-31T00:11:01Z")

</div>

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

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

* * *

**EDIT**

I think i miss-read.

You want to set msg.paylod to "number zero" if it contains `[false, false, false, false, false, false, false, false]` ?

---

<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:** [31 January 2021 00:20 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075/3 "2021-01-31T00:20:40Z")

</div>

Perhaps this?...

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

demo flow...

```auto
[{"id":"93704910.d87f58","type":"inject","z":"766a1068.58afb","name":"[true, false, false, false, false, false, false, false]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[true, false, false, false, false, false, false, false]","payloadType":"json","x":320,"y":740,"wires":[["716e29a.fb62cd8"]]},{"id":"592b3e8.38b91c","type":"inject","z":"766a1068.58afb","name":"[false, false, false, false, false, false, false, false]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[false, false, false, false, false, false, false, false]","payloadType":"json","x":320,"y":700,"wires":[["716e29a.fb62cd8"]]},{"id":"716e29a.fb62cd8","type":"json","z":"766a1068.58afb","name":"","property":"payload","action":"","pretty":false,"x":600,"y":720,"wires":[["953c2964.cbced8"]]},{"id":"953c2964.cbced8","type":"switch","z":"766a1068.58afb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"[false,false,false,false,false,false,false,false]","vt":"str"},{"t":"cont","v":"[true,false,false,false,false,false,false,false]","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":720,"wires":[["2907ddef.853382"],["b6d7e003.016e8"]]},{"id":"2907ddef.853382","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":700,"wires":[["2253905c.f66ee"]]},{"id":"b6d7e003.016e8","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":740,"wires":[["5b51a92d.1044e8"]]},{"id":"2253905c.f66ee","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":700,"wires":[]},{"id":"5b51a92d.1044e8","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":740,"wires":[]},{"id":"2290b159.5d67de","type":"comment","z":"766a1068.58afb","name":"V1 (explicit)","info":"","x":220,"y":660,"wires":[]},{"id":"588fb527.0286ec","type":"inject","z":"766a1068.58afb","name":"[false, false, false, false, false, false, false, false]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[false, false, false, false, false, false, false, false]","payloadType":"json","x":320,"y":840,"wires":[["d9c7b496.f23338"]]},{"id":"b4b13926.859578","type":"inject","z":"766a1068.58afb","name":"[true, false, false, false, false, false, false, false]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[true, false, false, false, false, false, false, false]","payloadType":"json","x":320,"y":880,"wires":[["d9c7b496.f23338"]]},{"id":"d9c7b496.f23338","type":"change","z":"766a1068.58afb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0] = true ? 1 : 0\t\t ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":860,"wires":[["55e89d81.20b2f4"]]},{"id":"55e89d81.20b2f4","type":"debug","z":"766a1068.58afb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":860,"wires":[]},{"id":"41d1f450.daad9c","type":"comment","z":"766a1068.58afb","name":"V1 (only check first element)","info":"","x":260,"y":800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![vaughan.mcd](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@vaughan.mcd](https://discourse.nodered.org/u/vaughan.mcd)\
**Post date:** [31 January 2021 01:54 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075/4 "2021-01-31T01:54:32Z")

</div>

Yes that worked, I used the 2nd version to check just the first element my case.  
Thanks 👌

---

<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:** [1 April 2021 01:55 UTC](https://discourse.nodered.org/t/change-node-change-payload-from-array-to-number/40075/5 "2021-04-01T01:55:04Z")

</div>

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