I tried to find a cool guide how rendering JSON with Grails wo开发者_运维百科rks, the documentation on official website - to me - very little information.
which articles you used that to understand how it works?
Thanks.
I think this documentation is sufficient. You install the converters plugin and then render the response object as json:
def list = {
def listResult = [ total: Book.count(), items: Book.list(params)]
render listResult as JSON
}
It depends on what you mean by understanding how it works. If you really want to understand the how, the best thing to do is get the source code from Grails and step through it. If you just need to understand how to use it, the documentation is more than adequate. What exactly are you having problems with?
Documentation: http://grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1.7 XML and JSON Responses
精彩评论