Groovy web console

subscribe to the feed Subscribe
to this
site

why not dump json slurper output directlu

Published 3 weeks ago by Jocelyn
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def incidentlist = []

def incident = [:]
incident.ticketId = "1"
incident.summary= "interface down"
incident.status= "open"
incident["sum.arry"] = "it's not me"
incidentlist.add(incident)

def incident2 = [:]
incident2.ticketId = "2"
incident2.summary= "cpu threshold breached"
incident2["sum.arry"] = "it's not me"
incident2.status= "closed"
incidentlist.add(incident2)

println incidentlist


def incidentClosed = []

incidentlist.each(){
    if(it.status == "closed"){
        println it.ticketId
        println "it's closed"
        //incidentClosed.add(it)
        tempMap = [:]
        it.each(){
            tempMap[it.key.replace(".","_")] = it.value.toString()
        }
        incidentClosed.add(tempMap)
    }
}

println incidentClosed