I'm looking for a way to add object roots to my JSON in grails (2.4.5). Generally, Grails renders JSON list of objects like so:
[{"id":1,"title":"Catan","description":"Catan"}]
But I need it to look like:
{"games": [{"id":1,"title":"Catan","description":"Catan"}]}
Ideally I'd like to adjust the custom marshaller I've created to do this, but I'm not sure how to go about it:
class GameMarshaller {
void register() {
JSON.registerObjectMarshaller(Game) { Game node ->
return [
id : node.id,
title : node.title,
description : node.description
]
}
}
}