【发布时间】:2020-10-04 09:26:24
【问题描述】:
我需要通过 asp.Net Web API 提供下面提到的 JSON 输出。 此输出将用于以角度显示组织层次结构(树视图)。
我在 SQL 表中有员工数据如下:
EMP_NO EMP_NAME DESIGNATION Manager_ID
所需的 JSON 输出:
myobject= {
"parent":[
{
"name":"radha Acharya",
"designation":"General Counsel",
"state":"",
"active":false
},
{
"name":"Rakesh mishra",
"designation":"General Counse2",
"state":"",
"active":false
},
{
"name":"Suri patil",
"designation":"General Counse3",
"state":"",
"active":true
}
],
"childs":[
{
"name":"child 1",
"designation":"Deputy General Counsel",
"state":"",
"active":false,
"hasChilds":true
},
{
"name":"child 2",
"designation":"Deputy General Counsel",
"state":"",
"active":false,
"hasChilds":true
},
{
"name":"child 3",
"designation":"Deputy General Counsel",
"state":"",
"active":false,
"hasChilds":false
},
{
"name":"child 4",
"designation":"Deputy General Counsel",
"state":"",
"active":false,
"hasChilds":true
},
{
"name":"child 5",
"designation":"Deputy General Counsel",
"state":"Resigned",
"active":false,
"hasChilds":true
},
{
"name":"child 6",
"designation":"Deputy General Counsel",
"state":"",
"active":false,
"hasChilds":true
}
]
}
在角度它会像这样显示 Front end display image
【问题讨论】:
-
你将如何从 JSON 输出中确定谁是谁的孩子?
标签: c# sql asp.net-mvc asp.net-web-api webapi