我已经实现了域类:
package xxx
class Machine {
String name
static constraints = {
}
}
而且我还有一项服务:
package xxx
import javax.ws.rs.Path
import javax.ws.rs.GET
import javax.ws.rs.Produces
import grails.converters.JSON
import org.json.simple.JSONObject
@Path('/api/machine')
class MachineService {
@GET
@Produces(['application/json'])
def String readAll() {
Machine.findAll() as JSON
}
}
输出是:
[{"class":"xxx.Machine","id":1,"name":"test1"},{"class":"xxx.Machine","id":2,"name":"test2 "},{"class":"xxx.Machine","id":3,"name":"test3"}]
我想删除字段“类”。你能告诉我达到这个目标的最简单方法吗?