public string DataTableToJson(DataTable dt) { StringBuilder strbuding = new StringBuilder(); strbuding.Append("["); for (int i = 0; i < dt.Rows.Count; i++) { strbuding.Append("{"); for (int j = 0; j < dt.Columns.Count; j++) { strbuding.Append("""); strbuding.Append(dt.Columns[j].ColumnName); strbuding.Append("":""); strbuding.Append(dt.Rows[i][j].ToString()); strbuding.Append("","); } strbuding.Remove(strbuding.Length - 1, 1); strbuding.Append("},"); } strbuding.Remove(strbuding.Length-1,1); strbuding.Append("]"); return strbuding.ToString(); }