I have the following code to implement JSON in Groovy:
def index = {
def list = WordList.list()
render(contentType:"text/json"){
LISTS {
for(item in list){
LIST (NAME: item.name, ID: item.id);
}
}
}
}
Which almost works but it doesnt show multiple results i.e. the NAME and ID fields get overwritten on each cycle resulting in only the last record getting returned. What is the correct syntax to get this working?