How do I use just the values of a saved vector?

Hi

I have a variable called updatedTickets that has the following -

{“id”:“Vector(53216e5a-9de9-49df-a63c-c0354f3d923b, fc47251b-7948-4865-a20e-4474b93052ba)”}

I would like to use just the values of the vector in the subsequent call

i.e I would like the body to be -

{ "id": ["53216e5a-9de9-49df-a63c-c0354f3d923b", "fc47251b-7948-4865-a20e-4474b93052ba"] }

This doesn’t work as it sends everything

.exec(http(“POST to Encrypted Tickets”)

.post("/planner_tools/v1/event_api/events/${eventId}/tickets_encrypted")

.body(StringBody( “”"{“id”:"${updatedTickets}"}""")).asJSON

.check(bodyString.exists)

.check(status.is(200)))

How do I send just the values?

Thank you

p.s - Sorry if this is more scala vs gatling, still trying to get the hang of this.

`

`

.exec(http(“POST to Encrypted Tickets”)

.post("/planner_tools/v1/event_api/events/${eventId}/tickets_encrypted")

.body(StringBody( “”"{“id”:"${updatedTickets}"}""")).asJSON

.check(bodyString.exists)

.check(status.is(200)))

Hi,

“${updatedTickets}” is resolved as “Vector(53216e5a-9de9-49df-a63c-c0354f3d923b, fc47251b-7948-4865-a20e-4474b93052ba)” because gatling is calling the method toString on updatedTickets which prints that way.

If you want to instead print values as [“value1”, “value2”, etc.], you will need to use a combination of map to put the values between quotes, and mkString (with start/separator/end) to pretty print the array itself.

Cheers!

Gatling EL has a toJsonString function. Please have a look at the doc.

I think you mean jsonStringify(), I got closer after this. Only problem, I have now is to remove the quotes as it does it like this now.

{“id”:"[“63518c9c-6a1e-4ec8-bd2b-9aebbc637567”,“435973e3-7d14-42e3-8585-06a01b1f8d35”]"}

Is there an inbuilt way to do that?

You’re the one who wrote those outer quotes, not Gatling.

Yes, I am an idiot, thank you!

No pro :slight_smile: