我有一个域类:
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
}
如何在不使用 _business.gson 模板的情况下为业务对象生成 JSON?
我想采用一种只有 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?**
}