1.
def oList = [total:0, rows:[]]
oList['total'] << Role.count()
oList['rows'] << Role.list(params)
render oList as JSON
输出结果:
{"total":0,"rows":[[]]}
2.
def om = [
success : false,
info : '',
data : [],
error : ''
]
om.success = true
om.data << [total: Role.count(), rows:Role.list(params)]
render om as JSON
输出结果:
{"success":true,"info":"","data":[{"total":1,"rows":[]}],"error":""}
3.
def om = [
success : false,
info : '',
data : [],
error : ''
]
om.success = true
om.info = "数据加载成功!"
om.data << [total: Role.count(), rows:[Role.list(params)]]
println om.data as JSON
输出结果:[{"total":1,"rows":[[]]}]