groovy - ghdrako/doc_snipets GitHub Wiki

each - problem

https://stackoverflow.com/questions/3049790/can-you-break-from-a-groovy-each-closure

JSON

  1. JsonSlurperJsonSlurper is a class that parses JSON text or reader content into Groovy dataStructures such as maps, lists and primitive types like Integer, Double, Boolean and String.
  2. JsonOutputThis method is responsible for serialising Groovy objects into JSON strings.
new JsonSlurper().parseText(response.content)

JSON slurper parses text or reader content into a data structure of lists and maps.

def jsonSlurper = new JsonSlurper()
      Object lst = jsonSlurper.parseText('{ "List": [2, 3, 4, 5] }')
      lst.each { println it }