在下面的代码中,我正在构建具有作者和标题的 Book.groovy json ..我的问题来自 Book.groovy 我如何删除商店字段..我尝试了以下方法,在渲染之后我仍然在我的 json 响应中看到商店
def book_custom_list(Integer max) {
println "In book_custom_list"
book_instance.authors.titles.remove('stores')
book_instance.each { e ->
println e.authors.titles
}
render .......
}
Domain Controllers
Book.groovy
class Book {
String name
static hasMany = [authors: Author]
static constraints = {
}
@Override
public String toString() {
name
}
}
作者.groovy
class Author {
String name;
static hasMany = [titles : Title]
static constraints = {
titles cascade: "all-delete-orphan"
}
}
标题.groovy
class Title {
Stores stores
Date dateCreated
}
JSON:
{
"id": 1,
"name": "test",
"authors": [
{
"id": 1,
"name": "sdsd",
"titles": [
{
"id": 7,
"stores": {
"id": 8,
}
"dateCreated": "Sep 25, 2013 12:50:42 PM",
}
]
}]
}