【发布时间】:2020-07-28 06:45:58
【问题描述】:
我正在使用函数以树格式获取数据。从 GetDepotWithDepartment 返回的数据作为字符串数据类型。如何将字符串转换为 JsonResult
public JsonResult GetDepotDepartemntsForMap()
{
string lson = _unitOfWork.Department.GetDepotWithDepartment();
return lson // error is coming cannot convert string into mvc.jsonREsult
}
来自给定存储库 linq 的数据
[
{
"id": 1,
"title": "1-Depot1",
"subs": [
{
"id": "1.1",
"title": "1.Advt"
},
{
"id": "1.2",
"title": "1.Admin"
}
]
},
{
"id": 2,
"title": "2-Depot2",
"subs": [
{
"id": "2.1",
"title": "2.Sales"
},
{
"id": "2.2",
"title": "2.Admin"
}
]
}
]
【问题讨论】:
-
卡兰,我试过同样的方法,但没用
-
它已经是 json.... 你为什么要把它转换成 json?