Reputation: 31
I have a situation where I need to concatenate two strings 1 and 2.
Str1: {"CodeName":"service:batch","data":{"prId":${TestId},"filters":[{
Str2: "tallId":
To look like:
{"CodeName":"service:batch","data":{"prId":${TestId},"filters":[{"tallId":
Have tried:
Str1 = Str1 + "\"tallId\":";
Upvotes: 0
Views: 4008
Reputation: 168197
So I would recommend reconsidering your approach using Groovy language as it has built-in JSON support so you should be able to create a "good" JSON Object from JMeter Variables without having to worry about quotation marks, commas, etc.
Upvotes: 1
Reputation: 983
Put the below code in your beanshell script area:
String Str1 = vars.get("mainString");
String Str2 = "\"teamId\":";
String Str3 = Str1 + Str2;
vars.put("NewString", Str3);
Upvotes: 0