# Extract from array ,object

**URL:** <https://discourse.nodered.org/t/extract-from-array-object/85592>\
**Category:** Dashboard\
**Created:** [16 February 2024 14:25 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592 "2024-02-16T14:25:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![telescopio](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@telescopio](https://discourse.nodered.org/u/telescopio)\
**Post date:** [16 February 2024 14:25 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/1 "2024-02-16T14:25:46Z")

</div>

Need some help to extract form an Object

```auto
2/16/2024, 10:20:06 AM[node: debug 90](http://127.0.0.1:1880/#)

msg.payload : array[1]

array[1]

0: object

intemp: "81.1"

unit: "F"

inhumi: "38%"

abs: "29.95 inHg"

rel: "29.95 inHg"

```

Need to extract the values for intemo,inhumi,abs,arel  
individual to display as a text.

```auto
[
    {
        "id": "7da2e023f84a2dcc",
        "type": "inject",
        "z": "f464957002a4d7f4",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 140,
        "wires": [
            [
                "38dcf0f25307b8ab"
            ]
        ]
    },
    {
        "id": "38dcf0f25307b8ab",
        "type": "http request",
        "z": "f464957002a4d7f4",
        "name": "",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://10.0.4.54/get_livedata_info?",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 290,
        "y": 240,
        "wires": [
            [
                "3bc27ec8fbe07fca"
            ]
        ]
    },
    {
        "id": "3bc27ec8fbe07fca",
        "type": "split",
        "z": "f464957002a4d7f4",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 470,
        "y": 220,
        "wires": [
            [
                "3e2fe869e378fa50",
                "bd2a9c7d2f5272ea"
            ]
        ]
    },
    {
        "id": "3e2fe869e378fa50",
        "type": "debug",
        "z": "f464957002a4d7f4",
        "name": "debug 90",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 160,
        "wires": []
    },
    {
        "id": "a0da53b7dd6d2f89",
        "type": "ui_text",
        "z": "f464957002a4d7f4",
        "group": "241820d172e65d1d",
        "order": 22,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "text",
        "format": "{{msg.payload[0].intemp}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 890,
        "y": 180,
        "wires": []
    },
    {
        "id": "bd2a9c7d2f5272ea",
        "type": "function",
        "z": "f464957002a4d7f4",
        "name": "function 15",
        "func": "msg.payload.intemp\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 220,
        "wires": [
            [
                "a0da53b7dd6d2f89"
            ]
        ]
    },
    {
        "id": "241820d172e65d1d",
        "type": "ui_group",
        "name": "MAIN POWER",
        "tab": "76c1d76e82d63ff5",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "76c1d76e82d63ff5",
        "type": "ui_tab",
        "name": "OBS",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

```

This Is what I am working on

Thanks

---

<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:** [16 February 2024 14:51 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/2 "2024-02-16T14:51:27Z")

</div>

Hi, i have updated your post for readability and to prevent the forum making your flow un-importable.

In future, please use the `copy value` button to copy _good_ format data from messages and payloads - shown when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

Also, always wrap data/code/flows/logs in a code block

`````  
`code here between three backticks `  
`````

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 February 2024 15:00 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/3 "2024-02-16T15:00:04Z")

</div>

I'm not convinced that you need the split node.

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

Move your debug node to the output of your http request. Then, as @Steve-Mcl shows, you can find the path to the element[s] you want.  
I think, for example, temperature is at `msg.payload[0].intemp`

In your function node you have this

```auto
msg.payload.intemp
return msg;

```

Just the name of element msg.payload.intemp, even if it exists, does nothing with it.

Could it be that you wanted something like this? (Look, no functions!)

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

---

<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 2024 15:16 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/4 "2024-02-16T15:16:16Z")

</div>

Are the Change nodes even needed, You could just use {{msg.payload[0].intemp}} or {{msg.payload[0].inhumi}} in the text nodes.

But as jbudd says, show the output of the http request node, so we can all be sure of the exact data.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 February 2024 15:18 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/5 "2024-02-16T15:18:28Z")

</div>

Nope, change nodes not needed. Mind you, my illustration would be less self explanatory without them!

---

<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 2024 15:22 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/6 "2024-02-16T15:22:32Z")

</div>

> [@jbudd](#):
>
> Mind you, my illustration would be less self explanatory without them!

Debatable, you could name the text nodes similarly to the way you did with the change nodes.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 February 2024 15:29 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/7 "2024-02-16T15:29:24Z")

</div>

If i'd have thunk of that i'd have dun it! 😟

---

<div class="post-metadata">

**Author:** ![telescopio](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@telescopio](https://discourse.nodered.org/u/telescopio)\
**Post date:** [16 February 2024 15:51 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/8 "2024-02-16T15:51:12Z")

</div>

> [@E1cid](#):
>
> {{msg.payload[0].inhumi}}

Thansk to all I was close, but your knowledge is super

---

<div class="post-metadata">

**Author:** ![telescopio](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@telescopio](https://discourse.nodered.org/u/telescopio)\
**Post date:** [16 February 2024 16:31 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/9 "2024-02-16T16:31:31Z")

</div>

jbudd

I add another sensor and now I received this object, Can you Please help me out to be able to display object 4,5,6,7. Thanks In advance for your time

/16/2024, 12:25:35 PM[node: debug 90](http://127.0.0.1:1880/#)

msg.payload : array[10]

array[10]

0: object

1: object

2: object

3: object

4: object

id: "0x0B"

val: "0.00 mph"

5: object

id: "0x0C"

val: "0.00 mph"

6: object

id: "0x19"

val: "17.22 mph"

7: object

id: "0x15"

val: "2.21 W/m2"

---

<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:** [16 February 2024 16:32 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/10 "2024-02-16T16:32:21Z")

</div>

> [@telescopio](#):
>
> msg.payload : array[10]
> 
> array[10]
> 
> 0: object
> 
> 1: object
> 
> 2: object
> 
> 3: object
> 
> 4: object
> 
> id: "0x0B"
> 
> val: "0.00 mph"
> 
> 5: object
> 
> id: "0x0C"
> 
> val: "0.00 mph"
> 
> 6: object
> 
> id: "0x19"
> 
> val: "17.22 mph"
> 
> 7: object
> 
> id: "0x15"
> 
> val: "2.21 W/m2"

As i said before...

> [@Steve-Mcl](#):
>
> In future, please use the `copy value` button to copy _good_ format data from messages and payloads - shown when you over hover a debug message property in the sidebar.
> 
> ![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)
> 
> Also, always wrap data/code/flows/logs in a code block
> 
> ```auto
> `code here between three backticks `
> 
> ```

---

<div class="post-metadata">

**Author:** ![telescopio](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@telescopio](https://discourse.nodered.org/u/telescopio)\
**Post date:** [16 February 2024 16:49 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/11 "2024-02-16T16:49:26Z")

</div>

Sorry, I think now that I may get what you said.Let me know is this is good.

```auto
[
  {"id":"0x02","val":"--.-","unit":"F"},
  {"id":"0x07","val":"--"},
  {"id":"3","val":"--.-","unit":"F"},
  {"id":"0x03","val":"--.-","unit":"F"},
  {"id":"0x0B","val":"0.00 mph"},
  {"id":"0x0C","val":"0.00 mph"},
  {"id":"0x19","val":"17.22 mph"},
  {"id":"0x15","val":"1.74 W/m2"},
  {"id":"0x17","val":"0"},
  {"id":"0x0A","val":"228","battery":"5"}
]

```

I copy the value of the object, or I need to do it individual like this

```auto
{"id":"0x0B","val":"0.00 mph"}

```

Luis RIvera

* * *

_Admin edit: wrap code in ````` code block ```_

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [16 February 2024 17:01 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/12 "2024-02-16T17:01:59Z")

</div>

> [@telescopio](#):
>
> can you Please help me out to be able to display object 4,5,6,7

I thought we had given you sound advice before.

> [@jbudd](#):
>
> Move your debug node to the output of your http request. Then, as @Steve-Mcl shows, you can find the path to the element[s] you want.

---

<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 2024 18:12 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/13 "2024-02-16T18:12:11Z")

</div>

Two possible routes depending on if the array of object always has the same order.

I think you would gain some more insight into node-red if you watched these [essentials videos](https://m.youtube.com/watch?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6&v=ksGeUD26Mw0&embeds_referring_euri=https%3A%2F%2Fnodered.org%2F&source_ve_path=OTY3MTQ&feature=emb_imp_woyt)

Example flows

```auto
[{"id":"1b77de4539b79cb2","type":"debug","z":"d1395164b4eec73e","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.val","targetType":"msg","statusVal":"payload","statusType":"auto","x":820,"y":5460,"wires":[]},{"id":"e8f3faaab5afb0df","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":5340,"wires":[["ad03663e3fc51aa7"]]},{"id":"54e60a80d26d8c2b","type":"inject","z":"d1395164b4eec73e","name":"if order can be different","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":\"0x03\",\"val\":\"--.-\",\"unit\":\"F\"},{\"id\":\"0x0B\",\"val\":\"0.00 mph\"},{\"id\":\"0x0C\",\"val\":\"0.00 mph\"},{\"id\":\"0x19\",\"val\":\"17.22 mph\"},{\"id\":\"0x15\",\"val\":\"1.74 W/m2\"},{\"id\":\"0x02\",\"val\":\"--.-\",\"unit\":\"F\"},{\"id\":\"0x07\",\"val\":\"--\"},{\"id\":\"3\",\"val\":\"--.-\",\"unit\":\"F\"},{\"id\":\"0x17\",\"val\":\"0\"},{\"id\":\"0x0A\",\"val\":\"228\",\"battery\":\"5\"}]","payloadType":"json","x":380,"y":5340,"wires":[["e8f3faaab5afb0df"]]},{"id":"e42d18a01a6e78b5","type":"inject","z":"d1395164b4eec73e","name":"Array order always the same","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":\"0x02\",\"val\":\"--.-\",\"unit\":\"F\"}, {\"id\":\"0x07\",\"val\":\"--\"}, {\"id\":\"3\",\"val\":\"--.-\",\"unit\":\"F\"}, {\"id\":\"0x03\",\"val\":\"--.-\",\"unit\":\"F\"}, {\"id\":\"0x0B\",\"val\":\"0.00 mph\"}, {\"id\":\"0x0C\",\"val\":\"0.00 mph\"}, {\"id\":\"0x19\",\"val\":\"17.22 mph\"}, {\"id\":\"0x15\",\"val\":\"1.74 W/m2\"}, {\"id\":\"0x17\",\"val\":\"0\"}, {\"id\":\"0x0A\",\"val\":\"228\",\"battery\":\"5\"}]","payloadType":"json","x":400,"y":5220,"wires":[["ea8c8eae791a06dd","6d4a0b42074decfe","13625d0488d2850b"]]},{"id":"ea8c8eae791a06dd","type":"debug","z":"d1395164b4eec73e","name":"msg.payload[4].val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload[4].val","targetType":"msg","statusVal":"payload[4].val","statusType":"auto","x":630,"y":5160,"wires":[]},{"id":"6d4a0b42074decfe","type":"debug","z":"d1395164b4eec73e","name":"msg.payload[5].val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload[5].val","targetType":"msg","statusVal":"payload[4].val","statusType":"auto","x":630,"y":5220,"wires":[]},{"id":"13625d0488d2850b","type":"debug","z":"d1395164b4eec73e","name":"msg.payload[6].val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload[6].val","targetType":"msg","statusVal":"payload[4].val","statusType":"auto","x":630,"y":5280,"wires":[]},{"id":"ad03663e3fc51aa7","type":"switch","z":"d1395164b4eec73e","name":"route on msg.payload.id","property":"payload.id","propertyType":"msg","rules":[{"t":"eq","v":"0x0B","vt":"num"},{"t":"eq","v":"0x0C","vt":"str"},{"t":"eq","v":"0x19","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":570,"y":5400,"wires":[["fcbf5eb9b794a3fb"],["dc6a916b731cde9d"],["1b77de4539b79cb2"]]},{"id":"fcbf5eb9b794a3fb","type":"debug","z":"d1395164b4eec73e","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.val","targetType":"msg","statusVal":"payload","statusType":"auto","x":820,"y":5340,"wires":[]},{"id":"dc6a916b731cde9d","type":"debug","z":"d1395164b4eec73e","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.val","targetType":"msg","statusVal":"error_count","statusType":"auto","x":820,"y":5400,"wires":[]}]

```

 ![chrome_screenshot_16 Feb 2024 18_15_29 GMT](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e38e636c7483668383c3aef863698389f3b431ca.png)

---

<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:** [17 March 2024 18:12 UTC](https://discourse.nodered.org/t/extract-from-array-object/85592/14 "2024-03-17T18:12:26Z")

</div>

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