Saving and reusing JSON response

I get json response something like the following:

“sg_crd_org_id”:“888888”,“sg_uaf_ind”:“N”,“sg_full_name”:[“Test LAST_NM”],
“sg_nm_address”:[“ADD1 |C/o |Street |STE |CITY STATE_CD zip | “,
“ADD2 |C/o |Street |STE |CITY STATE_CD zip”,
“ADD3 |C/o |Street |STE |CITY STATE_CD zip”,
“ADD4 |C/o |Street |STE |CITY STATE_CD zip”],


How can I parse this entire json in key value pair, so, I can reuse it again in the same request(another Ajax call).

I found some json stuff on Checks page but since I am not using as a check but as a way to populate another request I am not sure if thats the right way to do it.


Ok the following works and gets me bodyString but how do I access this variable


println “${jsonBody}” prints {jsonBody}

To answer your question, you will need to be a little more specific about the follow-on request. Can you post a more complete code sample, even if it is only conceptual?

Here is my code: (work in progress, of course)

val scn = scenario("SGSimulation") .exec(http("Snapshot") .get("""/snapshot?id=20011461&ns=U01JVEggSk9ILE4&cs=35622353""") .resources(http("request_1") .get(uri1 + """/data/customerInfo?customerId=20011461&listId=0&wt=json""")// Json output needs to massaged and passed on to another ajax call below //.check(jsonPath("$").findAll.saveAs("pList")) .check(bodyString.saveAs("jsonBody")) http("request_30") .get(uri2 + """?&callback=angular.callbacks._4&facetType=json&q=firm:{JSON_OUTPUT""")// This is one the places I will passing the json output. ))

I am very new gatling. Will appreciate your help.


In the URI of an http() request, you can use EL to add values stored in the session. Same thing with headers and request body.

Just extract the part you need in the .check of the request that is providing it to you, store it in appropriate session variables, and then embed those variables in future requests.

Exactly how you do the “massaging” depends on what kind of massaging you need to do. But you can always insert an .exec( session => … ) statement in between to do the massaging programmatically.

Ok. Will try it. Thanks a lot!