Reputation: 19854
I'm attempting to convert my Map<String, TableEntry>
to JSON in my controller as follows
def index() {
// get tables
JSON.use('deep')
render(tables) as JSON
}
My TableEntry
is a non-domain class as I do not wish to persist it
class TableEntry {
String teamName
Integer gamesPlayed = 0
Integer gamesWon = 0
Integer gamesDrawn = 0
Integer gamesLost = 0
Integer points = 0
// other methods
However, when my JSON is rendered in the client, I get the following:
'Team A':TableEntry@3b52fb28, 'Team Z':TableEntry@44e71d85
How do I get this to convert fully?
Upvotes: 2
Views: 270
Reputation: 4779
Your render statement is incorrect. You have:
render(tables) as JSON
However, it should read:
render tables as JSON
By wrapping the variable "tables" in parenthesis, the render is happening before you can cast "tables" to JSON.
Upvotes: 1