2
我試圖我Map<String, TableEntry>
轉換成JSON在我的控制器如下的Grails:將非域類JSON
def index() {
// get tables
JSON.use('deep')
render(tables) as JSON
}
我TableEntry
是一種非域類,因爲我不希望它堅持
class TableEntry {
String teamName
Integer gamesPlayed = 0
Integer gamesWon = 0
Integer gamesDrawn = 0
Integer gamesLost = 0
Integer points = 0
// other methods
然而,當我的JSON在客戶端呈現,我得到如下:
'Team A':[email protected], 'Team Z':[email protected]
我如何得到這個完全轉換?
我也有這個語法的問題,這取決於表達式的複雜性,所以我通常使用'render(表格作爲JSON)'來確保'as'正確應用 – 2014-11-02 00:45:14