# Testing script - how to get value from the proprerty in double nested array

**URL:** <https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663>\
**Category:** Help Hub\
**Created:** [March 22, 2019, 9:22am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663 "2019-03-22T09:22:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![piterwy](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@piterwy](https://community.postman.com/u/piterwy)\
**Post date:** [March 22, 2019, 9:22am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663/1 "2019-03-22T09:22:19Z")

</div>

Hi All,

I have a problem with retrieving the “id” value from the property in double nested arry. Is it possible?

 ![payload2](https://us1.discourse-cdn.com/getpostman/original/3X/3/7/37480b2f2812619da4626789c157bcb282fb4f21.jpeg)

Teest Script:  
var jsonData = pm.response.json();  
console.log(‘Test 1 for jobReqId:’, jsonData.d.results[0].jobReqId);  
console.log(‘Test 2 for status \> id:’, jsonData.d.results[0].status.id);  
console.log(‘Test 3 for status \> id:’, jsonData.d.results[0].status.results[0].id);

Outcomes:  
Test 1 - returns “145”  
Test 2 - returns “null”  
Test 3 - returns “Cannot read property ‘0’ of undefined”

Any help appreciated!

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [March 22, 2019, 9:26am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663/2 "2019-03-22T09:26:13Z")

</div>

Hey @piterwy,

Could you replace the image with the raw code please, makes it easier to have a look at the problem locally. 🙂

Danny

---

<div class="post-metadata">

**Author:** ![piterwy](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@piterwy](https://community.postman.com/u/piterwy)\
**Post date:** [March 22, 2019, 10:02am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663/3 "2019-03-22T10:02:08Z")

</div>

Hi @danny-dainton,

First, I want to Thank You for willing to help!

I have just found the problem:

- forgot to expand “status” 😊

Now:

- Test 3 - returns “11397”
- Test 2 - will not work because of the wrong syntax

Leaving this post - maybe will help somebody…

---

<div class="post-metadata">

**Author:** ![postman-paul540](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/postman-paul540/32/149_2.png) [@postman-paul540](https://community.postman.com/u/postman-paul540)\
**Post date:** [March 25, 2019, 9:23am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663/4 "2019-03-25T09:23:03Z")

</div>

@piterwy  
Don’t you mean you forgot to expand the second “results” array?

```auto
// Your original failing test:
console.log("Test 2 for status > id:", jsonData.d.results[0].status.id);
// This returns null

console.log("Test 2 for status > id:", jsonData.d.results[0].status.results[0].id);
// This returns "11397"

```

---

<div class="post-metadata">

**Author:** ![piterwy](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@piterwy](https://community.postman.com/u/piterwy)\
**Post date:** [March 26, 2019, 11:44am UTC](https://community.postman.com/t/testing-script-how-to-get-value-from-the-proprerty-in-double-nested-array/4663/5 "2019-03-26T11:44:15Z")

</div>

@postman-paul540  
Yes, this is what I meant - I forgot to expand “status” complex property in the API call.
