# Accessing nested objects and arrays using the new code node

**URL:** <https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367>\
**Category:** Questions\
**Tags:** code\
**Created:** [December 1, 2022, 5:03pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367 "2022-12-01T17:03:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pford](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pford/32/3174_2.png) [@pford](https://community.n8n.io/u/pford)\
**Post date:** [December 1, 2022, 5:03pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/1 "2022-12-01T17:03:01Z")

</div>

## Describe the issue/error/question

Hi I just upgraded by instance to the latest version to make use of the new Code node, but realized it works a bit differently than it used to. Im trying to return a nested array from a previous HTTP request. The output is showing only 1 item, but there is an array of numerous item with that object that I need to pull out. Is there a way to use dot notation like with the old Function node?

 ![Screen Shot 2022-12-01 at 12.00.06 PM](https://europe1.discourse-cdn.com/n8n/original/3X/2/6/264071b63e9dc0357dd094595365114433d2e692.png)

## Information on your n8n setup

- \*\*n8n version:0.204.0
- \*\*Database you’re using (default: SQLite):default
- \*\*Running n8n with the execution process [own(default), main]: own
- \*\*Running n8n via [Docker, npm, n8n.cloud, desktop app]:Docker-compose

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [December 2, 2022, 10:49am UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/2 "2022-12-02T10:49:27Z")

</div>

Hey @pford,

Can you share the input json and what you are expecting the output json to look like? In theory the code node should work the same but some of the internal variables have been changed so if you were to use `.all()` it would be the same as using `.items` in the old function node so you would still need to loop over the data although if there is only item you could just do `$("node name").first().json.nfts`

---

<div class="post-metadata">

**Author:** ![pford](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pford/32/3174_2.png) [@pford](https://community.n8n.io/u/pford)\
**Post date:** [December 2, 2022, 12:55pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/3 "2022-12-02T12:55:20Z")

</div>

Gotcha. Basically the input on the left is the result of an HTTP node, but the API returns the array “nfts” inside of a JSON object, so it says there’s only one item. I’d like to pull out that “nfts” array so that there are, say, 30+ items that I can then perform code on for each item in the array.

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [December 2, 2022, 1:15pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/4 "2022-12-02T13:15:52Z")

</div>

Hey @pford,

Pefect, Give `$("node name").first().json.nfts` a bash and see if it works.

---

<div class="post-metadata">

**Author:** ![pford](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pford/32/3174_2.png) [@pford](https://community.n8n.io/u/pford)\
**Post date:** [December 2, 2022, 2:12pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/5 "2022-12-02T14:12:31Z")

</div>

Wonderful, yes that worked perfectly!

 ![Screen Shot 2022-12-02 at 9.11.39 AM](https://europe1.discourse-cdn.com/n8n/original/3X/5/f/5f4d31cb464543c20679d34a921358d1bec9306d.png)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [December 9, 2022, 2:13pm UTC](https://community.n8n.io/t/accessing-nested-objects-and-arrays-using-the-new-code-node/20367/6 "2022-12-09T14:13:02Z")

</div>

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