Feed scenarios with JSON received from a REST service

Happy new year everybody.

I’m bugging (me) on something…

Our way of feeding data has been decided, we can’t use csv file either json file (too static, to map on any database, without having each time job to do). We will write some REST Services to interrogate the databases (all intelligence stays on the application-server side, nothing is written in gatling except it’s own scripts).
These REST servicies return JSON object in String format.

Example :

private val usersData: String = RestUrlCall.getRestContent("")

Which may returns, depending on databases these type of string, for examples :

[{"id":1144,"name":"NEDOQUE MAX"},{"id":1080,"name":"BLOCQUEAU JULIE"},{"id":1081,"name":"DIETY LILY"}]

I Parse this with Jackson :

val jObject = Jackson.parse(usersData)
(which works fine, I got an ArrayList in return)

And here is where I’m stucked…

How to feed my scenario with these data?
How to transform my parsed String into FeederBuilder[_] ?

Hope the question is not that stupid…

Thank you.


There are multiple ways to achieve this.

  1. You can build a custom feeder - http://gatling.io/docs/2.1.2/session/feeder.html
  2. Here is a JSON feeder - http://gatling.io/docs/2.1.2/session/feeder.html#json-feeders

Thank you for helping me.

  1. I really thought it was THE solution, I tried… but obviously I did not understand how this works… I couldn’t write it…
  2. I already looked at the JSON feeder but they have to be either in a diskFile or downloadable through an URL, so I can use none of them…

Do someone has en example of a custom build feeder please?

Thank you.

JsonFeeder looks straightforward and simple Can you tell me how you tried it? Can you share your simulation?

The simplest way to implement it would be something like the following:


val myFeeder = jsonUrl("[](")

object test {
val myLoadTest = feed(myFeeder)
                  .exec(http("name of test").get("<your load test app url>")
                  .queryParam("id", "${id}") // id from your json array
                  .queryParam("name", "${name}") // name from your json array.


But since I don’t know what you are trying to do with the data, I am not sure if this will work.

Holly SH### it was so simple that I never tryed it this way … :frowning:
So you just solve my problems…

Thank you very much.
( I’m quite disapointed I didn’t find it on my own, but… )


@Abhinav Nice job helping here, thanks a bunch!

Just paying it forward :slight_smile:

Hi Abhinav,

Could you please help me on the Json Feeder?