How to use groovy builder to generate an array-type json?
We can generate an object-type json by groovy's json builder: def builder = new groovy.json.JsonBuilder() def root = builder.people { person { firstName 'Guillame' lastName 'Laforge' // Named arguments are valid values for objects too address( city: 'Paris', country: 'France', zip: 12345, ) married true // a list of values conferences 'JavaOne', 'Gr8conf' } } def jsonStr = builder.toString() I like this type of syntax, but how to build an array-type json? E.g. [ {"code": "111", "value":"222"}, {"code": "222", "value":"444"} ] I found some documents which say we should use JsonBuilder()