grails中JSON转换的问题

gemscorpio 2012-02-05
    def list() {
		def list = Building.list()
		render(contentType: "text/json") {
			Rows = list
			Total = Building.count().toString()
		}
	}

代码如上,这个返回的是
{"Rows":[{"class":"basic.Building","id":1,"dateCreated":"2012-02-05T09:05:18Z","lastUpdated":"2012-02-05T09:05:18Z","name":"第一教学楼"}],"Total":"1"}

这样的格式,但是我的ID想要"id":"1"的格式,请问题要怎么处理。
gemscorpio 2012-02-05
render(contentType: "text/json") {
			Rows = list.collect(){
			  [
				  id:it.id.toString(),
				  name:it.name,
				  dateCreated:new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(it.dateCreated),
				  lastUpdated:new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(it.lastUpdated)
			  ]
			}
			Total = Building.count().toString()
		}

搞定了,找到答案了
Global site tag (gtag.js) - Google Analytics