algorithm - data manipulation in javascript -


i have array of information containing folders this:

[                {                   "aclid" : 0,                   "id" : 100,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "04/12/2012 17:38:46",                   "issubfolder" : 0,                   "name" : "piyush1",                   "objecttype" : 3,                -->"parentid" : 3,                   "policyid" : 2,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "04/12/2012 17:38:46"                },                {                   "aclid" : 0,                   "id" : 102,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "05/10/2012 12:38:25",                   "issubfolder" : 0,                   "name" : "new",                   "objecttype" : 3,                -->"parentid" : 3,                   "policyid" : 2,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "05/10/2012 12:38:25"                },                {                   "aclid" : 0,                   "id" : 103,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "05/14/2012 18:00:22",                   "issubfolder" : 0,                   "name" : "segfolderwithdiffpolicy",                   "objecttype" : 3,                -->"parentid" : 3,                   "policyid" : 39,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "05/14/2012 18:00:22"                },                {                   "aclid" : 0,                   "id" : 104,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "05/17/2012 14:13:56",                   "issubfolder" : 0,                   "name" : "new1",                   "objecttype" : 3,                -->"parentid" : 100,                   "policyid" : 2,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "05/17/2012 14:13:56"                },                {                   "aclid" : 0,                   "id" : 105,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "05/17/2012 14:14:13",                   "issubfolder" : 0,                   "name" : "abcasdna",                   "objecttype" : 3,                -->"parentid" : 104,                   "policyid" : 2,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "05/17/2012 14:14:13"                },                {                   "aclid" : 0,                   "id" : 106,                   "auditinfoversion" : 3435973836,                   "createby" : 2,                   "createdate" : "05/18/2012 12:51:39",                   "issubfolder" : 0,                   "name" : "new2",                   "objecttype" : 3,                -->"parentid" : 100,                   "policyid" : 2,                   "sdescription" : "",                   "updateby" : 2,                   "updatedate" : "05/18/2012 12:51:39"                }             ] 

now required type of data is:

[{     name:'piyush1',     children: [{         name: 'new1',         children:[{             name: 'abcasdna'         }]     },{         name: 'new2'     }] },{     name: 'new' }] 

now thing there number of folders , level of hierarchy.

so there way can achieve conversion?


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -