Gatling - Extract Json value from previews request

I'm new in Gatling, and trying to get value from json key.

This check give me labels:

.check(jsonPath("$[1].ppp[1].label").saveAs("label"))

In this request i got all json data like this

[
  {
    "id":258,
    "code":"D00CC3056",
    "label":"Test-0"
  },
  {
    "id":260,
    "code":"D00RR148",
    "label":"Test-1"
  }
]

From this Json, i need to get code value from a specific label, to use it in request after.

Something like : get code where label is "Test-1".

I've trying this but doesn't works:

        .exec(
            http("request_3:GET_/api/code")
            .get("/api/code")
            .check(status.is(200))
            .check(jsonPath("$..[*].code").find("{$label}").saveAs("code"))
        )

I don't know how to do this.

Any help ?


With JMESPath that you should really learn and that Gatling supports:

.check(jmesPath("[?label == 'Test-1'].code").saveAs("code"))