# Fetch value of a key which has "-" in Tests

**URL:** <https://community.postman.com/t/fetch-value-of-a-key-which-has-in-tests/6112>\
**Category:** Help Hub\
**Created:** [June 26, 2019, 7:43am UTC](https://community.postman.com/t/fetch-value-of-a-key-which-has-in-tests/6112 "2019-06-26T07:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunilammanabrolu](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sunilammanabrolu](https://community.postman.com/u/sunilammanabrolu)\
**Post date:** [June 26, 2019, 7:43am UTC](https://community.postman.com/t/fetch-value-of-a-key-which-has-in-tests/6112/1 "2019-06-26T07:43:05Z")

</div>

I have a json response as below  
{  
…  
{  
…  
},  
“status”: {  
“ldap-servers”: [  
{  
“result”: “Connect\_Success”,  
“message”: “ldap connection check successful”,  
“server”: {  
“url”: “192.168.129.188:389”  
}  
},  
{  
“result”: “Connect\_Failure”,  
“message”: “LDAP Result Code 200 "Network Error": dial tcp 192.168.129.188:386: connect: connection refused”,  
“server”: {  
“url”: “192.168.129.188:386”  
}  
}  
]  
}  
}

I tried below in Tests and it gives an error  
pm.test(“LDAP Connection test”, function () {  
var jsonData = pm.response.json();  
pm.expect(jsonData.status.ldap-servers[0].result).to.eql(“Connect\_Success”);  
});

LDAP Connection test | ReferenceError: servers is not defined

How do I escape the character “-” in pm.expect?

Postman version: 7.2.0

---

<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:** [June 26, 2019, 7:50am UTC](https://community.postman.com/t/fetch-value-of-a-key-which-has-in-tests/6112/2 "2019-06-26T07:50:47Z")

</div>

This is a duplicate question, you can find the answer here:

> [@Help with JSON extraction](https://community.postman.com/t/help-with-json-extraction/5155):
>
> Hi. I am doing my first steps towards an “advanced” use of Postman. I am trying to extract data from a JSON response. The JSON response looks like: { "args": {}, "headers": { "x-forwarded-proto": "https", "host": "postman-echo.com", "accept": "\*/\*", "accept-encoding": "gzip, deflate", "cache-control": "no-cache", "cookie": "sails.sid=s%3AgX-JxoOgGc7tWEb8jw\_6YBH5VKcxH8R8.M7J38uMcN090VYnxRHu6eF4rkq7arAemQXhfRd9TWz4", "postman-token"…

---

<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:** [June 26, 2019, 7:56am UTC](https://community.postman.com/t/fetch-value-of-a-key-which-has-in-tests/6112/3 "2019-06-26T07:56:01Z")

</div>

@sunilammanabrolu  
You want to use the bracket notation to find that “ldap-servers” in your scenario.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/0/4057d00066230b78759e4bc89baf08a8894a973f.png)

You can read about the two methods here:

> **[JSON Literals](https://www.w3schools.com/js/js_json_objects.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

And here’s an example of what your test might look like.

```plaintext
pm.test("LDAP Connection test", function () {
    pm.expect(jsonData.status["ldap-servers"][0].result).to.equal("Connect_Success");
});

```
