Hello mrarkapravo
Just because your attribute values came from JSON, doesn't mean putting them together is still JSON. Like ChrisAdams said, you are just showing a list of strings with curly brackets around them which does not make it JSON.
I would propose just a list of strings that you can store as a property value. When you need that list in some other step you will need to manipulate it slightly to form a listObject since anything stored as a property is only a string value. listObj -> string (property) -> listObj.
Some sample code that might meet your need. It is just a way to pass list object around your test steps by keeping content in properties. You could also just put the list object into the context of the running testcase and it would be available to other test steps (but only available during the run of the test case as a whole)...
log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" start...';
log.info "";
// example... not json
def notValidJSONStr = '{"123", "234"}';
log.info "notValidJSONStr=$notValidJSONStr";
// ====== Set a list to properties
def strList = [];
strList.add("123");
strList.add("234");
log.info "strList=$strList";
strList.each {
log.info it.trim();
};
context.conList = strList;
// set list to string for storage in properties...
testRunner.testCase.testSteps['Properties'].setPropertyValue("strList", strList.toString());
log.info "-------------- transform ------------------";
// ====== Get a list from properties
// get content of string property and restore it to list object...
def differentStr = context.expand( '${Properties#strList}' );
log.info "differentStr=$differentStr";
// lose the brackets surrounding the strings
// if using ReadyAPI...
//differentStr = differentStr.takeBetween('[', ']');
// if using SoapUI or ReadyAPI...
differentStr = differentStr.substring(1, differentStr.length() - 1);
log.info "differentStr=$differentStr";
// now get back to a list
def differentStrList = differentStr.tokenize(',');
differentStrList.each {
log.info it.trim();
};
log.info "";
log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" done...';
In the event you want the context from another groovy test step in the same test case (take it or leave it). I prefer just putting it in a property (illustrated above) since I can debug it better than running the whole test case to get context.
log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" start...';
log.info "";
strList = context.conList;
strList.each {
log.info it.trim();
};
log.info "";
log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" done...';