颜健鸥,哈尔滨建站多少钱,网上药店哪个好
标准的json用“分隔,不用'
public static string DataSetToJson(DataTable dt)
{ string json = string.Empty; try { if (dt==null||dt.Rows.Count == 0) { return ""; } json = "{"; json += "'table" + 1 + "':["; for (int i = 0; i < dt.Rows.Count; i++) { json += "{"; for (int j = 0; j < dt.Columns.Count; j++) { json += "'" + dt.Columns[j].ColumnName + "':'" + dt.Rows[i][j].ToString() + "'"; if (j != dt.Columns.Count - 1) { json += ","; } } json += "}"; if (i != dt.Rows.Count - 1) { json += ","; } } json += "]"; json += "}"; } catch (Exception ex) { throw new Exception(ex.Message); } return json; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论