I have a list of files sorted in an array, like:
arr = ["./a.txt", "./b.txt", "./bar/z.php", "./foo/hello/y.php", "./foo/x.php"]
How to create a dynatree object out of this? A dynatree object for it, should look like:
[{"name"=>".", "title" => ".", "isDir" => true, "children" =>
[{"name"=>"a.txt", "title" => "a.txt"},
{"name"=>"b.txt", "title" => "b.txt"},
{"name" => "bar", "title"=>"bar", "isDir"=>true, "children" =>
[{"name" => "z.php", "title" => "z.php"},
{"name" => "foo", "title" => "foo", "isDir" => true, "children" =>
[{"name" => "x.php", "title" => "x.php"},
{ "name" => "hello", "title" => "hello", "children" =>
[{"name" => "y.php", "title"=>"y.php"}
]
}
]
}
]
}
]
}]
PS: This question might seem a lazy post, but I have spent more than 20 hrs now solving this. So any help will be greatly appreciated. Thanks.