Javascript:
var key1 = execution.getVariable(‘key1’);
var key2 = execution.getVariable(‘key2’);
var temp = {
‘variable1’:key1,
‘variable2’: key2
}
execution.setVariable(‘jsonobject’,S(JSON.Stringify(temp)));
above script successfully stores the created object in json format.
I want to achieve the same in groovy script, so far this is what i have written
def key1 = execution.getVariable(‘key1’);
def key2 = execution.getVariable(‘key2’);
def temp = [
‘variable1’:key1,
‘variable2’: key2
]
execution.setVariable(‘jsonobject’,groovy.json.JsonObject.toJson(temp));
but in groovy i am not able to store the created temp as jsonObject.
Please assist on this
thank you