mattsmith5
mattsmith5

Reputation: 1153

Gatling Scala: Reading JSON Data

How do I feed JSON data into Gatling Scala? This line of code will take in comma delimited csv. Trying to edit code for json below

object GetProductScenario {
  val csvData = csv("data/get_products.csv").circular

  def exportScenario(): ScenarioBuilder = {
    scenario("Get Products")
      .exec(
        forever() {
          feed(csvData)
            .exec(GetProducts.searchData())
        }
      )
  }

JSON:

{
  "productId": 1,
  "name": "book",
  "amount": 17,

Upvotes: 0

Views: 176

Answers (1)

Stéphane LANDELLE
Stéphane LANDELLE

Reputation: 6623

Have a look at StringBody or ElFileBody where you can use patterns like #{productId} to inject the desired values.

Upvotes: 0

Related Questions