Posted by & filed under grails.

Recently I started to play with Grails 2.3.4 and discovered a lot of nice features around REST, grails team did really good progress here.

When I was playing I noticed that I always had “class” field in JSON returned to me by grails server when I checked the doc, it was saying that you need to setup JSON renderer like this in resources.groovy file:

But when I tried it, it did not work. Well, it did not work for index method, which was returning a collection of devices. You need to define 2 beans: one for collection rendering and another for single object:

Now it will work. Same stands for xml, just use XmlCollectionRenderer instead.

One Response to “Grails 2.3 exclude class in json/xml renderer not working”

  1. Brandon

    Thanks for the awesome tip. I started developing a RESTful API for a legacy database today and experienced this same problem.

Leave a Reply

  • (will not be published)