How can i evaluate an expression extracted from a file?

Im using ssv feeder, and there’s some variables that i use to send in request body. One of these variables is a json, and inside this json variable, there’s a specific field that needs to be dynamically generated.

this is one example from ssv file


the “metadata” field must pass through a validation to get the session attributes called “cpf” andd “randIdProc”

The metadata is placed in this ssv because the json content is not always the same, so i cant simply put “dr:cpf” and “dr:idProcesso” fixed in the request body

I´ve done this in JMeter, but i have no idea on how to make this using gatling

Hi @Vinicius,

Why is it a variable? As the content is generated, I think that only variables should be in the file.
Then you will be able to use an another file as json template (with pebble?) to inject your variables from the feeder AND the dynamically generated variable (you previously stored in session).

Is that something working for you?

Or please, provide more specific example.
But If you really want have json in the feeder and modifying the json before sending it, I think you will have to use your own parser (you may use the one provided with Gatling, but we can change this internal dependency any time)


Gatling Expression Language doesn’t work recursively so it’s not possible.

You would have to code this yourself with the Session API, eg:

  StringBody( session -> {
     String template = session.getString("template");
     String randIdProc = session.getString("randIdProc");
     String cpf = session.getString("cpf");
     return template.replace("#{randIdProc}", randIdProc).replace(#{cpf}, cpf);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.