0
後,我有一個Grails控制器動作返回一個JSON對象更改Grails的JSON對象創建
def someAction(String customerParameter) {
JsonBuilder json = new JsonBuilder()
def jsonObject = json {
someAttribute "someValue"
} as JSON
// TODO: if customerParamter is not null add it to json object
render (contentType: 'application/json;charset=UTF-8', text:json)
}
如前所述上面的代碼,我想修改的JSON對象不使用或不給予重建它customerParameter。
你不需要'JsonBuilder'無論是。如果您打算使用'grails.converters.JSON',我們只需要一張地圖(我假設這裏使用了這個) – dmahapatro