使用Newtonsoft将DataTable转Json
Newtonsoft提供的将DataTable转成Json:
/// <summary> /// DataTable转Json /// </summary> /// <param name="dt"></param> /// <returns></returns> public static string ToJson(this DataTable dt) { return Newtonsoft.Json.JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.Converters.DataTableConverter()); }