As input I have list of all objects where each object has properties:
- name
- children(object.children is the list of all children)
- parent(null if object is top level)
How correctly to use Groovy JSONBuilder to render such data(depth of tree is unlimited):
-Object 1
--Object 1.1
---Object 1.1.1
--Object 1.2
-Object 2
in JSON format it should be something like this:
[
{
"name":"Object1",
"children":[
{
"name":"Object1.1",
"children":[
{
"name":"Object 1.1.1",
"children":[]
}
]
},
{
"name":"Object1.2",
"children":[]
}
]
},
{
"name":"Object2","children":[]
}
]
This is needed to build JSON for extJS component which will display this tree. Thanks for your help!
Add this property to your Config.groovy file:
The Grails Doc
is a little out of date but the relevant property is listed there under ‘Configuration Options’