title: Gatling: Transforming response and writing it to JSON file
body: <p>Fairly new to Scala/Gatling and I have searched the SO a lot, but nothing specific to my issue has been answered. So here's my code </p>
  
  <pre><code>    val adminUplFile: ScenarioBuilder = scenario("Admin user uploads file")
      .exec(http("Upload File")
        .post("/file") 
        .header("username", "example") r
        .header("password", "80HL/d1fETqxuCArAbIU6/Sb3F2nSTCqw/eqw1lzJio=") 
        .formUpload("file", "uploadFile") // body params ("key" , "path of the file/name")
        .formParamSeq(Seq(("uploadByID", "1"), ("location", "meetings"), ("personID", "0"), ("uploadTimeStamp", "2019-01-15 10:01:04.426"), ("md5Hash", "n95QI48+Uqxfw0hTnJdqMA=="))) 
        .check(status.is(200)) 
        .check(jsonPath("$.uuid").saveAs("guidList"))) 
      .exec { session =&gt;
      val writer = new PrintWriter(new FileOutputStream(new File("src/gatling/resources/extractedData/GuidList.json"), true))
      writer.write(session("\"guidList\"").as[String].trim)
      writer.write("\n")
      writer.close()
      session  }
  
  setUp(
      adminUplFile.inject(constantUsersPerSec(2) during (1 seconds)).protocols(httpConf)
    )
  </code></pre>
  
  <p>and here's the response I'm trying to extract :</p>
  
  <pre><code> {
      "uuid": "3a917e22-3c76-45de-a104-4e2aa4b72a35"
  }
  </code></pre>
  
  <p>So what I get written to the file is :<br>
  "3a917e22-3c76-45de-a104-4e2aa4b72a35"<br>
  "929c89c0-7a1a-4a18-8ee8-2958c9cd430f"</p>
  
  <p>and what I want is :<br>
  [</p>
  
  <p>"3a917e22-3c76-45de-a104-4e2aa4b72a35" ,<br>
  "929c89c0-7a1a-4a18-8ee8-2958c9cd430f"</p>
  
  <p>]</p>
  
  <p>just looking at it, it looks a simple case of adding square brackets and a comma to the file but in reality, with every virtual user trying to append the same file I'm struggling on how to make it format in a way that square brackets don't get used again and only once.</p>
  
  <p>So I don't want :<br>
  ["3a917e22-3c76-45de-a104-4e2aa4b72a35"],<br>
  ["929c89c0-7a1a-4a18-8ee8-2958c9cd430f"]</p>