I'm currently trying to use the Tree
class to build a tree-strucuture from a database query. Afterwards I want to convert it to a json object (with playframework api).
Some examples or a bit more documentation for the Tree
class would be awesome. I can't get my head arround the draw
and drawTree
method, which may do a similiar thing.
Example
val tree = ("Root", 100).node(
("Category1", 30).leaf,
("Category2", 20).node(
("Sub1", 15).leaf,
("Sub2", 3).leaf,
("Sub3", 2).leaf),
("Category3", 10).leaf,
("Category4", 30).node(
("Sub1", 20).leaf,
("Sub2", 5).leaf))
This should result in a json tree like this
{
"name" : "Root",
"value" : 100,
"children" : [
{
"name" : "Category1",
"value": 30
},
{
"name": "Category2",
"value": 20,
"children" : [
{
"name" : "Sub1",
"value" : 15"
} ....
]
]