Groovy web console

subscribe to the feed Subscribe
to this
site
TEST (via #groovywebconsole)
tweet this snippet Tweet
this
script

TEST

Published 1 month ago by DG
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonSlurper

def restResponse = '[{"agendaItemId":1, "delegateId":"1", "sponsorId":"1"},{"agendaItemId":1, "delegateId":"2", "sponsorId":"1"}, {"agendaItemId":1, "delegateId":"1", "sponsorId":"2"}]'
def list = new JsonSlurper().parseText( restResponse )

for (i = 0; i < list.size(); i++) {
    def tt = list.findAll {element -> element.delegateId == list[i].delegateId && element.agendaItemId== list[i].agendaItemId}
    println tt.size()
    if(tt.size() > 1) {
        println "fail"
    }
}