# How to extract value from array/object?

**URL:** <https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698>\
**Category:** General\
**Created:** [9 February 2021 18:35 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698 "2021-02-09T18:35:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marivesel](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@marivesel](https://discourse.nodered.org/u/marivesel)\
**Post date:** [9 February 2021 18:35 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698/1 "2021-02-09T18:35:37Z")

</div>

First to say hello!

I want to "extract" only the value data from an array/object.  
It's a capacity measurement from my solar battery, I need to sent the value only via MQTT.  
I'm now sending "col28: 260.00", but I need to sent only the value "260.00".  
I tried with an "change" function to set the msg.payload to "msg.payload.0.col28.Value[0]" as suggested on other thread I found with similar problem, but doesn't work, tried also every other combination like "msg.payload.col28.Value", etc...  
I have read the messages documentation, but there I can't find anything similar.

![t2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/4704fc135d604d2c661986f21810542e2c82935d.jpeg) ![t1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/ed758c96693fc4aa82bf231a6360286949311072.jpeg)

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [9 February 2021 18:41 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698/2 "2021-02-09T18:41:56Z")

</div>

Try `msg.payload[0].col28` as the array is msg.payload and the object is one layer down as an index of the array.

---

<div class="post-metadata">

**Author:** ![marivesel](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@marivesel](https://discourse.nodered.org/u/marivesel)\
**Post date:** [9 February 2021 19:13 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698/3 "2021-02-09T19:13:45Z")

</div>

That worked from the first try and now I'm sending the Value only, thank you so much, I was close to give up since I was trying this by myself for a few days... JGKK special thanks 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 February 2021 19:23 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698/4 "2021-02-09T19:23:26Z")

</div>

Well worth checking out [Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)  
for how to find/reach various parts of messages.

---

<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:** [23 February 2021 19:24 UTC](https://discourse.nodered.org/t/how-to-extract-value-from-array-object/40698/5 "2021-02-23T19:24:20Z")

</div>

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