I have objects that look like:
[<ltree_val: "1", contents: "blah">,
<ltree_val: "1.1", contents: "blah">,
<ltree_val: "1.1.1", contents: "blah">,
<ltree_val: "2", contents: "blah">,
<ltree_val: "2.1", contents: "blah">]
Where ltree_val determines their tree structure.
I need to generate something like...
[{ "data" : "1",
"children" :
[{ "data" : "1.1",
"children" :
[{ "data" : "1.1.1" }]
}]
},
{ "data" : "2" }]
Where I have children which are determined by an ltree value, which are themselves elements of the same object.
If I sort these objects by their ltree value, how can I create nested entries?
I'm open to either RABL or JBuilder. I'm totally lost.