Feed From Jsonfile

Hi everyone
I would like to know if it is possible to save all of a json content with the “saveas”
and then feed another request with the some of the content of this json :

For exemple from the request below

.check(jsonPath("$.members).findAll.saveAs(“member”)

and then in others requests use multiple parameters such as :

${members[0].name}

${members[1].age}

{
“squadName”: “Super hero squad”,
“homeTown”: “Metro City”,
“formed”: 2016,
“secretBase”: “Super tower”,
“active”: true,
“members”: [
{
“name”: “Molecule Man”,
“age”: 29,
“secretIdentity”: “Dan Jukes”,
“powers”: [
“Radiation resistance”,
“Turning tiny”,
“Radiation blast”
]
},
{
“name”: “Madame Uppercut”,
“age”: 39,
“secretIdentity”: “Jane Wilson”,
“powers”: [
“Million tonne punch”,
“Damage resistance”,
“Superhuman reflexes”
]
}
]
}

Thanks in advance for your help

Hi James,

IMHO, I will go with manipulating Json with Jackson (from gatling transitive dependencies) or with an external library.
Once you saved your “member” variable, you may do what you want.

Cheers,

Thanks for your quick reply

If I may ask , Do you have some Gatling example how to manipulate Json with Jackson, it will be great ! :slight_smile:

Regards

Other options:

  1. save your JsonPath content as a Map or an Array with ofType and then reinject what you want with Gatling EL that supports basic traversal
  2. directly transform your response payload into the next request one with a JMESPath check instead of a JsonPath one.