In my JMeter script i have defined a User Defined Variable i whose value is set to 1. Then i created a JSR22 pre-processor for my HTTP sample that just increments the value of i using the below code.
Integer intI = vars.get("i");
intI = intI + 1;
Integer intId = vars.get("id")
Integer intId = vars.get("id").toInteger();
As requested, the conclusion from the comments as answer:
vars.get() returns a
String which, when assigned to an
Integer gets implicitly converted to the corresponding ASCII value.
This can be observed in the snippet:
def v = "1"; Integer intId = v; println intId -> prints 49