# Extract value from a JSON Response Body

**URL:** <https://community.postman.com/t/extract-value-from-a-json-response-body/41344>\
**Category:** Help Hub\
**Tags:** json, response\
**Created:** [November 21, 2022, 10:37pm UTC](https://community.postman.com/t/extract-value-from-a-json-response-body/41344 "2022-11-21T22:37:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vegconomist](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vegconomist](https://community.postman.com/u/vegconomist)\
**Post date:** [November 21, 2022, 10:37pm UTC](https://community.postman.com/t/extract-value-from-a-json-response-body/41344/1 "2022-11-21T22:37:45Z")

</div>

Hi there,

I have the below response body and would like to save the “url” value from the property to a collection Variable.

```auto
{
    "status": "success",
    "pageStatus": 200,
    "scrapeDate": "2022/11/21",
    "scrapeHour": "21:24:29",
    "results": {
        "scopedto": ".class",
        "links": [
            {
                "text": "",
                "host": "abc.com",
                "url": "https://abc.com/defg/",
                "radiusContext": {
                    "parentText": "akajsdfhs",
                    "nextSiblingText": "akajsdfhs"
                }
            }
        ],
        "partialPaths": [],
        "imageUrls": [
            {
                "host": "example.com",
                "url": "https://www.example.com/kasjdhksdhfkjsdhkjhsdfk"
            }
        ]
    }
}

```

_I’ve already tried_:  
let response = pm.response.json();  
pm.collectionVariables.set(“url”, response.results.links.url);  
_or_  
pm.collectionVariables.set(“url”, response.results[0].links[0].url);  
and various variations of this.

I feel like I’m so close, but can’t figure it out.

I’ve googled around for things like “extract property JSON” and “select key value pair in JSON with javascript”, to no avail.

Any help is welcome. Thank you!

---

<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:** [November 21, 2022, 11:20pm UTC](https://community.postman.com/t/extract-value-from-a-json-response-body/41344/2 "2022-11-21T23:20:40Z")

</div>

> [@vegconomist](#):
>
> response.results[0].links[0].url

Looks like it should be `response.results.links[0].url`

The `results` property isn’t an array, it is an object so you wouldn’t need to specify an index.

---

<div class="post-metadata">

**Author:** ![vegconomist](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vegconomist](https://community.postman.com/u/vegconomist)\
**Post date:** [November 22, 2022, 8:22am UTC](https://community.postman.com/t/extract-value-from-a-json-response-body/41344/3 "2022-11-22T08:22:08Z")

</div>

Ahhhh, I was so close 😃  
Yep, that works, thank you very much!
