我們正在試圖獲得一個Grails 2.5項目的Grails工作3.3grails 3.3渲染JSON破碎?
我們有一個JSON API,即contolers與JSON正是如此迴應:
log.info("about to return json")
render(status: 200, contentType: 'application/json') {
[
'result': 9999,
'message': "hello"
]
}
的問題是,該出把總是「{}」。這是控制器方法的最後一個代碼。
如果我們這樣做:
render("hello")
我們得到 「你好」。
如果我們這樣做:
render(status: 200, contentType: 'application/json') {
result = 0
player = "hello"
}
我們也總是得到 「{{}」,這太瘋狂了!
任何想法?這在Grails 3.3中被破解了嗎?這個相同的代碼在Grails中完美工作2.5
目前,我們唯一能找到的解決方案是使用字符串連接來手動呈現JSON,這是乏味和容易出錯的。