0

Hi I am getting back a response like this in Gatling Get call:

[
 {"firstName":"John", "lastName":"Doe"},
 {"firstName":"Anna", "lastName":"Smith"},
 {"firstName":"Peter", "lastName":"Jones"}
]

I want the firstnames to be concatenated in a comma seprated String. What is the best way to do that without parsing the JSon using any external libraries?

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108

1 Answers1

0

This can be done by using two features of Gatling:

  1. JsonPath Check
  2. transform

So the code would look like the following:

.check(jsonPath("$.firstName").ofType[String].findAll.transform(_.mkString(",")).saveAs("firstName")));
Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108