【发布时间】:2018-11-06 15:55:50
【问题描述】:
我需要从我的输出 json 中删除斜杠。我在我的 API 控制器中使用的以下函数。但我仍然得到了结果。我怎样才能删除这个斜线?
public string GetEmployeeDetails(string AccessCard)
{
DataTable dt =GetEmployeeByAccessCard(AccessCard);
if (dt.Rows.Count>0)
{
string JSONresult;
JSONresult = JsonConvert.SerializeObject(dt);
string outputjson = JSONresult.Replace("\\", "");
return outputjson;
}
else
return "No Data found";
}
【问题讨论】:
-
可以参考这个链接并适配正则表达式:forums.asp.net/t/…
-
它不工作
-
@Vahid 从 json 中删除斜线的任何具体原因?您希望实现哪些特定功能?
-
我创建了一个 Web API。由于此功能,我需要以正确的格式获取 json。但我得到的是这样的。 "{\"ID\":\"3411\",\"AccessCardNo\":\"123569\",\"DP_EmpID\":\"63\",\"EmpOfficialID\":\"EMP020 \",\"emp.DP_Degree\":\"710\",\"emp.DP_DepartmentID\":\"699\",\"emp.DP_EmpFname\":\"Feras\",\"ActualDepartureDate\" :\"01/01/2099\",\"EmpStatus_HR\":\"保留\"}"
-
这是网络浏览器向您显示的内容,还是您在调试器中看到的内容?检查此链接也stackoverflow.com/questions/20312974/…
标签: asp.net json asp.net-web-api