# Function to extract details from nested objects

**URL:** <https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267>\
**Category:** General\
**Created:** [26 May 2021 10:43 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267 "2021-05-26T10:43:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://discourse.nodered.org/u/kelster101757)\
**Post date:** [26 May 2021 10:43 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/1 "2021-05-26T10:43:47Z")

</div>

Hello all,

I want to create a Function to extract id and last\_seen from the object below but im not sure how to get the 2nd object out.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/959725f1c306d7c6082a726239982e88202eb851.png)

For example, would expect to write

> msg.payload = [  
> {  
> measurement: msg.pyaload."eui-000080029c09e021".id  
> }  
> ]  
> return msg;

but I just get the error below "expected an indentifier and instead saw

> "eui-000080029c09e021"

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a3a7cefbb63e2752baf66637da6f959931e6f1a.png)

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:** [26 May 2021 10:44 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/2 "2021-05-26T10:44:34Z")

</div>

Use "copy path" to get the path to the item in the object (then add the `msg.` part to the begining)

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.

Pay particular attention to the part about the buttons that appear under your mouse pointer 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)

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

---

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://discourse.nodered.org/u/kelster101757)\
**Post date:** [26 May 2021 10:47 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/3 "2021-05-26T10:47:32Z")

</div>

brill got it, just the brackets i was missing

msg.payload["eui-000080029c09e021"].id

---

<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:** [26 May 2021 10:47 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/4 "2021-05-26T10:47:41Z")

</div>

you need to use square bracket notaion.

```auto
measurement: msg.pyaload["eui-000080029c09e021"].id

```

---

<div class="post-metadata">

**Author:** ![maiconcarlosp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maiconcarlosp/32/42645_2.png) [@maiconcarlosp](https://discourse.nodered.org/u/maiconcarlosp)\
**Post date:** [31 May 2021 01:30 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/5 "2021-05-31T01:30:01Z")

</div>

If I want to put the description value "UfL0\_..." in site of measurement key {measurement: ...} how may I do? Automatically.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 May 2021 08:04 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/6 "2021-05-31T08:04:12Z")

</div>

Welcome to the forum @maiconcarlosp

First, did you see @Steve-Mcl's post, marked as the solution to this thread, and have you read and understood it? If that didn't help then please give us more information on _exactly_ what you don't know how to do. Show an example of what you start with and what you want the result to be.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 May 2021 08:07 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/7 "2021-05-31T08:07:49Z")

</div>

I see that you asked the question again in a new thread. Please don't double post questions. I also notice that you marked as the solution exactly the solution shown earlier in this thread.

---

<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:** [14 June 2021 08:08 UTC](https://discourse.nodered.org/t/function-to-extract-details-from-nested-objects/46267/8 "2021-06-14T08:08:19Z")

</div>

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