# Addressing an object within an array

**URL:** <https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117>\
**Category:** General\
**Created:** [16 February 2021 19:26 UTC](https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117 "2021-02-16T19:26:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quentinP](https://avatars.discourse-cdn.com/v4/letter/q/ba9def/32.png) [@quentinP](https://discourse.nodered.org/u/quentinP)\
**Post date:** [16 February 2021 19:26 UTC](https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117/1 "2021-02-16T19:26:34Z")

</div>

Sorry for the basic question but I having some problems extrating my "count" as an integer from my payload when it comes back looking like this (result of an SQL query).

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/740289a4495f33f2baa66d7278e0e0201ed5b814.png)

I tried with a function node and this code:

```auto
// Stores the result of the SQL query locally (is the connecting device registered?)
//var arrResult = msg.payload
var registered = msg.payload[0];
msg.payload = registered;
return msg;

```

However, I get the following on the debug console:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c57c34de5fd91d991bf0912424158c040df29a9.png)

Cheers!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 February 2021 19:40 UTC](https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117/2 "2021-02-16T19:40:08Z")

</div>

Sort you sql query out  
`SELECT count(*) AS myCount FROM table;`  
then you will get a friendly name format

or use `msg.payload[0]["count(*)"]`

---

<div class="post-metadata">

**Author:** ![quentinP](https://avatars.discourse-cdn.com/v4/letter/q/ba9def/32.png) [@quentinP](https://discourse.nodered.org/u/quentinP)\
**Post date:** [16 February 2021 19:53 UTC](https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117/3 "2021-02-16T19:53:31Z")

</div>

Perfect, thanks so much!

---

<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:** [2 March 2021 19:54 UTC](https://discourse.nodered.org/t/addressing-an-object-within-an-array/41117/4 "2021-03-02T19:54:24Z")

</div>

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