1

I have below JSON response from an API, To verify if the status is completed, I have written below code:

* match each response contains deep {Status:'Completed'}

but this fails for the status where the status is in lower case 'completed' instead of 'Completed'

how to solve this issue?

Also if I want to check that each status is either 'Open' OR 'In-Progress', how to validate that?

[
{
"id": "1",
"Status":"Completed"
},
{
"id": "2",
"Status":"completed"
},
{
"id": "3",
"Status":"In-Progress"
},
{
"id": "4",
"Status":"Open"
}     
]
RF1991
  • 2,037
  • 4
  • 8
  • 17
Vinod
  • 55
  • 3

1 Answers1

0

Do a transform:

* def statuses = response.map(x => x.Status.toLowerCase())
* match each statuses == "#? _ == 'completed' || _ == 'in-progress' || _ == 'open'"

There are many other ways to do this. Read other answers for more hints: https://stackoverflow.com/a/62567262/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248