Reputation: 871
I need to print an array without parenthesis
part of a json file
"platforms": [
{
"platformCode": "EOS",
"platformCodeDescription": "Credit Card Servicing (Voyager) platform"
},
{
"platformCode": "OLB",
"platformCodeDescription": "Online Retail Bank Servicing Platform"
}
],
part of code
def list=json.loginModel.get("platforms")
log.info list
output is
[{platformCode=EOS, platformCodeDescription=Credit Card Servicing (Voyager) platform}, {platformCode=OLB, platformCodeDescription=Online Retail Bank Servicing Platform}]
if I use this code
def list=json.loginModel.get("platforms").platformCode
log.info list
output
[EOS, OLB]
i need the EOS and OLB without "[]"
and","
Upvotes: 0
Views: 2387
Reputation: 871
log.info json.loginModel.get("platforms").platformCode.get(0)
log.info json.loginModel.get("platforms").platformCode.get(1)
will print the desired result
Upvotes: 0
Reputation: 130
You could create a method like this one and pass your list:
public String printArray(String[] platfomrs){
String result = "";
for(String code:platfomrs)
result += result + code + " ";
return result;
}
Upvotes: 1