1.这里下载:http://www.newtonsoft.com/products/json/
安装:
1.解压下载文件,得到Newtonsoft.Json.dll
2.在项目中添加引用
2.引入命名空间
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Converters;
3.把datatable转换成json格式
public string GetAllCategory()
{
string result = "";
DataTable dt= catDAO.GetAllCategory();
result=JsonConvert.SerializeObject(dt, new DataTableConverter());
return result;
}
{
string result = "";
DataTable dt= catDAO.GetAllCategory();
result=JsonConvert.SerializeObject(dt, new DataTableConverter());
return result;
}