Extracting JSON response

Using Firefox RESTClient gives me the response(body) attached as screenshot.
Wanting to save i.e the “scanNumber” in this response, how do I write that in Gatling?
I have tried


But get error:

14:14:36.019 [WARN ] i.g.h.a.AsyncHandlerActor - Request ‘Login page’ failed: jsonPath(“scanNumber”:"").exists failed, could not extract: could not extract : $' expected but ’ found

Is there a way to print to console (in i.e IntelliJ) the reponse I am getting in the Simulation? This would be helpful.

Given that I have managed to save the response “responsevar” above is there an easy way to also print this to console in i.e IntelliJ?


And here is the screenshot.


Click on link on documentation and check the proper syntax.
JsonPath ≠ XPath

Looking at http://gatling.io/docs/2.0.0-RC5/http/http_check.html
this is still not clear to me.

Could you please elaborate? JSON is different from XPath, ok. But I miss a concrete example in the documentation.



I did make this work:


But this:



jsonPath($.memberships.scanNumber).exists, found nothing 5 (100,0%)

I guess I am getting closer, do I need the .check ? It should find “something” looking at the JSON response again:

{"resultCode":"SUCCESS","errorCode":null,"errorMessage":null,"profile":{"fullName":"TestFirstName TestMiddleName TestLastName","memberships":[{"name":"UA Gold Partner","number":"123-456-123-123","scanNumber":"123-456-123-123"}]}}

memberships is an array : $.memberships[0].scanNumber

Still not working with:


But this worked:


Thank you guys!

Woops : $.profile.memberships[0].scanNumber

For further info on JsonPath: http://goessner.net/articles/JsonPath/ (link is provided in the documentation).
You can also easily find online JSONpath expression testers.

is it a simple way to print the value of scanNumber saved as the variable “scanNr” in my question.
print to console in IntelliJ i.e.?


Add a session lambda to your scenario to print your value stored in the session, after it’s set by your check:

exec(session => {