【发布时间】:2017-11-08 15:00:40
【问题描述】:
我们希望根据父链接和显示顺序将 JSON 下方转换为树视图结构的父子关系。
- 如果父链接为空,则为父链接
- 如果存在父链接,则应将其添加为子链接
- 项目应根据显示顺序排序
[{
"ParentLink":{ },
"Id":1,
"Title":"Home ITSD test new",
"Url":{
"Description":"#",
"Url":"https://technologies.sharepoint.com/"
},
"DisplayOrder":1,
"IsActive":true,
"ID":1},{
"ParentLink":{
},
"Id":2,
"Title":"Link6",
"Url":{
"Description":"#",
"Url":"https://technologies.sharepoint.com/"
},
"DisplayOrder":2,
"IsActive":true,
"ID":2},{"ParentLink":{
"Title":"Link6"
},
"Id":3,
"Title":"link7",
"Url":{
"Description":"#",
"Url":"https://technologies.sharepoint.com/"
},
"DisplayOrder":21,
"IsActive":true,
"ID":3},{
"ParentLink":{
"Title":"Link6"
},"Id":4,
"Title":"link8",
"Url":{
"Description":"#",
"Url":"https://technologies.sharepoint.com/"
},
"DisplayOrder":22,
"IsActive":true,
"ID":4},{
"ParentLink":{
"Title":"link8"
},
"Id":5,
"Title":"link9",
"Url":{
"Description":"#",
"Url":"https://technologies.sharepoint.com/"
},
"DisplayOrder":221,
"IsActive":true,
"ID":5}]
是否有其他可用的库或任何简单的方法来做到这一点
【问题讨论】:
标签: javascript arrays json multidimensional-array treeview