Extract certain strings from JSON data strucure
Hello community,
I have the following JSON formatted data:
{
   "interfaces" : {
      "interface" : [
         {
            "interface-name" : "eth0"
         },
         {
            "interface-name" : "eth1"
         },
         {
            "interface-name" : "cons0"
         },
         {
            "interface-name" : "cons1"
         }
      ]
   }
}
I only want to have the strings"cons0" and "cons1" extracted/tansfered into e. g. an arrary for further usage in a SOAPUI test case. Does anyone has an idea?
Thanks in advance
Markus
- Hello Markus, - Given that you have a list of values that can vary between 0 and infinity, you can set properties from it easily enough, but now you have to give the property a name for each of those values. For each value a unique name must be created unless you don't care about how many values are in a list. The following builds on prior examples in this thread: - filteredInterfaceNameList = []; 
 interfaceNameList.each { name ->
 if (name.contains('cons')) {
 filteredInterfaceNameList.add (name)
 };
 };
 filteredInterfaceNameList.eachWithIndex { interfaceName, idx ->
 propName = "somePropertyNameValue" + idx.toString();
 propValue = interfaceName;
 testRunner.testCase.testSteps["Properties"].setPropertyValue( propName, propValue);
 };- . - . - . 
 You have never stated how you would use this dynamically, so I can only imagine... The above code allows you to dynamically write properties from 0 to infinity (or however many Smartbear will allow). :)