title: Gatling - Check if response body string key is certain value
body: <p>I have a scenario in Gatling and I want to check if the response body value maps to an error string. The response is a 400: </p>
  
  <pre><code>{"error": "ERROR_1"}
  </code></pre>
  
  <p>The check is failing with a compilation error:</p>
  
  <pre><code> http("Some Request")
    .put("/endpoint")
    .asJson
    .check(jsonPath("$.error") == "ERROR_1")
    .check(status.is(400))
  </code></pre>
  
  <p>Also tried saving the error as a variable</p>
  
  <pre><code>.check(jsonPath("$.error").saveAs("error"))
  .check("${error}" == "ERROR_1")
  </code></pre>
  
  <p>And realised the <code>.check("${error}".is("ERROR_1"))</code> won't work either since .is only works for ints. The gatling docs don't explain expressions too much either <a href="https://gatling.io/docs/current/http/http_check#validating" rel="nofollow noreferrer">https://gatling.io/docs/current/http/http_check#validating</a></p>
  
  <p>Any ideas? </p>