简体   繁体   中英

Gatling: How can I load a range from a JSON feeder file?

I have a feeder file with 10k objects and I would like to load objects 6000 to 6999. What I currently do is load the JSON, convert it to a list[object], extract the range and convert it back to JSON with the necessary range and then reload it as feeder... This seems very excessive to me and I was wondering if there is a way to do it at the reading JSON feeder file stage:

val feeder: FileBasedFeederBuilder[Any] = jsonFile(feederJson)

Thanks

What you say can be accomplished just like this:

val feeder = jsonFile("foo.json")
  .readRecords
  .filter { record =>
    val id = record("id").asInstanceOf[Int]
    id < 7000 && id > 5999
  }
  .toArray

val useCaseScenario: ScenarioBuilder =
  scenario("aaa")
    .feed(feeder)
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM