I thought that the JSON elements cannot be extracted directly within a JS using context.getVariable(). We can alternatively use Extract variable policy and extract using Jsonpath.
Here is what I did when i needed JSON element in JS - var payload = context.getVariable(“otpresponse.content”); var jsonObject= JSON.parse(payload); var otp = jsonObject.sessiontoken;