Hi,
I'm also very interested in this - I've never had to do it at all - but it seems like it would pop up sooner or later.
I did have a go at this myself - i knew it was a bit beyond me - but I thought I might be able to work it out with a bit of reading - but what I read said that the groovy count function doesnt appear to work with strings - it works with maps, arrays and collections - but when I get a json response I think I normally handle it as a string? so I dont know how to get it to work
so - apologies - I know this post isn't helpful at all - but at least I can show you what I've got so far
def json = new groovy.json.JsonSlurper().parseText(context.response) // its a string at this point - right?
assert json.Member.every{it == false || it = true}
//the above would assert that the repeating Member attribute displays either 'false' or 'true'
I found the following on groovy goodness site
def list = ['Groovy', 'Grails', 'Java']
assert list.count { it.startsWith('G') } == 2
def numbers = [1,2,3,4] as Integer[]
assert numbers.count { it > 2 } == 2
def map = [user: 'mrhaki', city: 'Tilburg', age: 37]
assert map.count { key, value -> key.size() == 3 } == 1
so I was trying to edit my original script using this - but I was unsuccessful
I updated my original script as follows:
def json = new groovy.json.JsonSlurper().parseText(context.response)
assert json.Member.count{it == false || it = true} // the script passed - but if Member contains other values <> false or true - the assertion still passes
but as I mention in the comment - this doesnt do what I need either!
Would welcome any hints/tips to steer me in the right direction!
As always - thanks to all!
rich