0
我有一個域類:如何在不定義內部模板的情況下使用Grails JSON視圖?
class Business {
String name
String description
}
我有以下的JSON模板:
index.gson
:生成JSON的對象
_business.gson
:生成JSON的業務對象
index.gson
import server.Business
model {
Iterable businessList
}
json {
result tmpl.business(businessList ?: [])
}
_business.gson
model {
Business business
}
json {
id business.id
name business.name
}
怎樣才能JSON的業務對象,而無需使用_business.gson模板嗎?
我想去一個方法,我只是有index.gson並手動渲染內部對象。
import server.Business
model {
Iterable businessList
}
json {
**WHAT SHOULD I ADD HERE?**
}
json(businessList.toList()) {
**I also noticed that I can use this syntax, BUT WHAT SHOULD I ADD HERE?**
}