For example, I have the following domain class
User{ String name }
I also have 2 objects of this class
new User(name: "John").save() new User(name: "Alex").save()
What the โlistโ action in UserController should look like to represent User.list () in JSON format, such as
{1: "John", 2: "Alex"}
Let me be more precise. I want something like this:
UserController{ def list = { render(contentType: "text/json") { User.list().each {user-> user.id = user.name } } }
But, unfortunately, this does not work.
vogdb source share