DtatTable转成Json格式
2020-12-13 04:44
标签:style c color int a string /// /// DataTable转成Json /// ///
/// publicstaticstring DataTableToJson(DataTable
dt) { StringBuilder
jsonBuilder = newStringBuilder();
jsonBuilder.Append("[");
for (int i = 0; i
{
jsonBuilder.Append("{");
for (int j = 0; j
{
jsonBuilder.Append("\"");
jsonBuilder.Append(dt.Columns[j].ColumnName);
jsonBuilder.Append("\":\"");
jsonBuilder.Append(dt.Rows[i][j].ToString().Replace("\"",
"\\\""));
jsonBuilder.Append("\",");
}
jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("},");
}
jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("]");
return jsonBuilder.ToString(); } DtatTable转成Json格式,搜素材,soscw.com DtatTable转成Json格式 标签:style c color int a string 原文地址:http://www.cnblogs.com/XiaoHunZhen/p/3733467.html
上一篇:开发必备的Windows小技巧