json 转换为Hashtable
/// <summary>
/// Json转Hashtable
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public static Hashtable Json2Hashtable(string json)
{
return JsonConvert.DeserializeObject<Hashtable>(json);
}
Json数组转Hashtable
/// <summary>
/// Json转Hashtable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json"></param>
/// <returns></returns>
public static List<T> Json2ListHashtable<T>(string json)
{
return JsonConvert.DeserializeObject<List<T>>(json);
}
dataSet 反序列化成 json
/// <summary>
/// 将dataset 换换为join 字符串
/// </summary>
/// <param name="ds"></param>
/// <returns></returns>
public string toSimpleJson(DataSet ds)
{
Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss'.'fff";
string result = JsonConvert.SerializeObject(ds, timeConverter); return result;
}
使用上面的方法 必须引用 :Newtonsoft.Json