Is there a way to remove the class field in a JSON converter?
Example:
import testproject.*
import grails.converters.*
emp = new Employee()
emp
My preferred way of doing this:
def getAllBooks() {
def result = Book.getAllBooks().collect {
[
title: it.title,
author: it.author.firstname + " " + it.author.lastname,
pages: it.pageCount,
]
}
render(contentType: 'text/json', text: result as JSON)
}
This will return all the objects from Book.getAllBoks() but the collect method will change ALL into the format you specify.