Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Currently to create json from a list of objects we have to do something like this:
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 } } }
I would like to write:
JsonBuilder json = new JsonBuilder ()
def map = json {
songs songs, { Song s ->
title s.title
}
}
It is less code and easier to use and read.
Implementation with tests and doc update is here: