Came across this strange result today trying to render a list of objects as JSON in Grails 2.0.4...(i know i\'m gonna regret asking this on account of something right under
The essence of your problem here is that the groovy compiler interprets
render x as JSON
to mean
render (x as JSON)
but it interprets
render (x) as JSON
to mean
(render x) as JSON
If a method name (in this case render) is followed immediately by an opening parenthesis, then only code up to the matching closing parenthesis is considered to be the argument list. This is why you need an extra set of parentheses to say
render ((x) as JSON)