次のようなフォルダーを含む情報の配列があります。
[
{
"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"
}
]
必要なデータのタイプは次のとおりです。
[{
name:'Piyush1',
children: [{
name: 'New1',
children:[{
name: 'abcasdna'
}]
},{
name: 'New2'
}]
},{
name: 'New'
}]
問題は、任意の数のフォルダーと任意のレベルの階層が存在する可能性があるということです。
この変換を達成する方法はありますか?