# checking the (json) response against the request data

**URL:** <https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729>\
**Category:** Gatling (Open-Source)\
**Created:** [November 20, 2014, 7:13pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729 "2014-11-20T19:13:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [November 20, 2014, 7:13pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/1 "2014-11-20T19:13:17Z")

</div>

I want to check that the userid I am requesting is being returned in the response (json)

I guess I have to use .check(jsonPath("$. is like ${userID}.

My json response is below and I want to check that the “number”: “123”

`

```auto

1. {
1. "resultCode": "SUCCESS",
1. "errorCode": null,
1. "errorMessage": null,
1. "profile":
1. {
1. "id": "555555555",
1. "fullName": "Jason Xeml",
1. "memberships":
1. [
1. {
1. "name": "thename",
1. "number": "123",
1. "scanNumber": "555-555-555-555"
1. }
1. ]
1. }
1. }

```

`

is equivalent to the ${userID} below:

`

.exec(  
http(“getUser”)  
.get("/user/account")  
.header( “X-Token”, “${userID}” )  
.check(status.is(200))  
.check(jsonPath("$.resultCode").is(“SUCCESS”))

**.check(jsonPath("$.profile.memberships[0].number" = “${userID}” )**  
**or:**  
**.check(jsonPath("$.profile.memberships[0].number" equals “${userID}” )**  
**or?.. how?**  
)

`

I think the first part “$.profile.memberships[0].number” works, but how do I say that is must be equivalent to the requests ${userID} ?  
using equals? using = or how?

Magnus

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [November 20, 2014, 7:19pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/2 "2014-11-20T19:19:30Z")

</div>

I am not 100% on this but try :-  
`**.check(jsonPath("$.profile.memberships[0].number").find.is("${userId}")**`

---

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [November 20, 2014, 7:26pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/3 "2014-11-20T19:26:01Z")

</div>

I seems:

`  
.check(jsonPath("$.profile.memberships[0].number").is("${userID}"))

`

works!  
I can try your suggestion also.

Thanx!

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [November 20, 2014, 7:52pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/4 "2014-11-20T19:52:23Z")

</div>

.find is implied if it is not explicitly specified.

---

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [November 20, 2014, 8:28pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/5 "2014-11-20T20:28:00Z")

</div>

Hi,  
What does that mean?

(.find is implied if it is not explicitly specified)

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [November 20, 2014, 8:48pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/6 "2014-11-20T20:48:39Z")

</div>

It means that specifying

`.check( jsonPath( path ).find.is( value ) )`

is exactly the same as specifying

`  
.check( jsonPath( path ).is( value ) )

`

---

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [November 20, 2014, 9:29pm UTC](https://community.gatling.io/t/checking-the-json-response-against-the-request-data/1729/7 "2014-11-20T21:29:42Z")

</div>

Thank you (again), John!
