Groovy web console

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

build json

Published 4 months ago by nmrao with tags jsonbuilder
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def users= ["a", "b", "c"]
def jsonBuilder = new groovy.json.JsonBuilder() 
jsonBuilder { reviewers users.collect { u ->
    return { user { name (u) } }
  }
}
println(jsonBuilder.toPrettyString())