//调用示例
DataTable tb = GetData();
JsonHelper.DataTableToJSON(tb, “tableName”);

//转换方法
public static string DataTableToJSON(DataTable dt, string dtName)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);

        using (JsonWriter jw = new JsonTextWriter(sw))
{
JsonSerializer ser = new JsonSerializer();
jw.WriteStartObject();
jw.WritePropertyName(dtName);
jw.WriteStartArray();
foreach (DataRow dr in dt.Rows)
{
jw.WriteStartObject();

foreach (DataColumn dc in dt.Columns)
{
jw.WritePropertyName(dc.ColumnName);
ser.Serialize(jw, dr[dc].ToString());
}

jw.WriteEndObject();
}
jw.WriteEndArray();
jw.WriteEndObject();

sw.Close();
jw.Close();

}

return sb.ToString();
}