该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
后台将对象转换成json格式的字符串
public StringBuilder DataSetToJson(DataSet ds)
{//把**中的数据转换成json格式的数据
StringBuilder json = new StringBuilder();
json.Append("[");
foreach (DataRow row in ds.Tables[0].Rows)
{
string id = row["id"].ToString();
string channel_id = row["channel_id"].ToString();
string title = row["title"].ToString();
string author = row["author"].ToString();
string createTime = row["createTime"].ToString(); string content = row["content"].ToString();
string clickCount = row["clickCount"].ToString();
string categoryId = row["categoryId"].ToString();
string zhaiyao = row["zhaiyao"].ToString();
string img_url = row["img_url"].ToString();
string digg_good = row["digg_good"].ToString();
string digg_bad = row["digg_bad"].ToString();
string is_comment = row["is_comment"].ToString();
string is_top = row["is_top"].ToString();
string is_red = row["is_red"].ToString();
string is_hot = row["is_hot"].ToString();
string is_lock = row["is_lock"].ToString();
string is_slider = row["is_slider"].ToString();
string sort_id = row["sort_id"].ToString();
json.Append("{\"id\":" + "\"" + id + "\",");
json.Append("\"title\":" + "\"" + title + "\",");
//json.Append("\"content\":" + "\"" + content + "\",");
json.Append("\"createTime\":" + "\"" + createTime + "\",");
json.Append("\"sort_id\":" + "\"" + sort_id + "\",");
json.Append("\"categoryId\":" + "\"" + categoryId + "\",");
json.Append("\"channel_id\":" + "\"" + channel_id + "\",");
json.Append("\"pageCount\":" + "\"" + pageCount + "\",");
if (row == ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1])
{//最后一行
json.Append("\"author\":" + "\"" + author + "\"}");
}
else
{
json.Append("\"author\":" + "\"" + author + "\"},");
}
}
json.Append("]");
return json;
}