I have following mapping representing categories tree:
class Category {
String name
static belongsTo = [parent: Category]
static hasMany = [categories: Category]
}
The thing I want to do is to render all of the category tree and exclude field parent
from rendering.
render category as JSON
renders only first level of hierarchy and doesn't render the names of child categories. I.e. having following tree:
Root->cat2->cat4 cat3
I have
{"class":"project.Category",
"id":1,
"categories":[{"class":"Category","id":2},
{"class":"Category","id":3}],
"name":"Root",
"parent":null}
I don't want "class" and "parent" attributes and want to see cat4 data in this tree.
Is there some special lib or plugin or maybe it is possible to config standard JSON converter or domain class?