I'm dealing with some problems with Jmeter. I do an HTTP request to an API, this API answer me in JSON, so I use a JSON extractor to extract the information that I need (I use the JSON path expression "$.asset_host" to get it and store it in a variable named "data"). So now I have a variable which is an array named "data" with data[0] = asset_host.
The problem is that I need to use this information in the next HTTP request but I don't know how to get asset_host from "data" without using a foreach controller. I tried ${data[0]}, ${data}[0], and ${data_0} but it doesn't work.
Do someone know how to get asset_host value at key 0 of array data please ?
EDIT
Here is the JSON response:
{
"chat_web_socket_port": "9009",
"assets_server": "\/\/assets.local",
"chat_web_socket_host": "chat",
"chat_web_socket_secure": false
}
EDIT_2
Ok I found why it doesn't work. The JSON response give me "//assets.local" so if I use it in the next request as host it puts "//assets.local" as host that's why it doesn't work. I will have to manipulate string to remove the "//".
EDIT_3
Ok just to finish this post, I used a JSR223 sampler to manipulate the string and remove the "//". I put the code here, maybe it will help someone esle in the future.
String assets = vars.get("assetServerHost_1");
String newAssets = assets.replace('//', '');
vars.put("hostForAssets", newAssets);
It's changing "//assets.local" to "assets.local"
Thank you for reading, and for your help.