How to save optional fields from json responses, avoiding "found nothing" errors?

Hello, I’m using Gatling 3.0 to test a system that uses json via websocket.

I send a request and get a json response, that has an array, which I need to save using checks.

{
“id”: “uuid-62af-11e9-b5d4-498d829bedde”,
“array”: [{“id”:1}, {“id”:2}, {“id”:3}]
}

Saving looks like this:

exec(api.call.check(jsonPath("$.array[*].id").findAll.saveAs("array_ids"))

Sometimes this array could be empty, and if so, backend doesn’t create empty array in json response.

{
“id”: “uuid-62af-11e9-b5d4-498d829bedde”
}

That way I get an error:

jsonPath($.array[*].id).findAll.exists, found nothing

But actually this is normal behaviour for my app.
Can’t find a way to fix this. For example in Jmeter I use assertions and extractor separately. Also extractors has a default value option for this situations.

Is there a common way to deal with this errors using Gatling?

https://gatling.io/docs/current/http/http_check/?highlight=optional#validating

Thank you, Stéphane!

Problem solved easily this way:

exec(api.call.check(jsonPath("$.array[*].id").findAll.**optional**.saveAs("array_ids"))