groovy/groovy-core — pull request #232 by hauner (2013-07-29 15:37:23+00:00)
Title: Json Builder feature

a small improvement to the json builder (https://jira.codehaus.org/browse/GROOVY-6159) that simplifies the handling of list of objects.

def songs = [new Song (title: "Title 1"), new Song (title: "Title 2"), ...]

JsonBuilder json = new JsonBuilder ()
def map = json {
songs songs.collect { Song s ->
json {
title s.title
}
}
}

can be written as:

JsonBuilder json = new JsonBuilder ()
def map = json {
songs songs, { Song s ->
title s.title
}
}