使用System.Runtime.Serialization.Json 解析Json 返回 hashtable 这样的方法吗
flyso 2015-03-30 03:33:34 使用System.Runtime.Serialization.Json 解析Json 返回 hashtable 这样的方法吗
我只知道返回List<T> 但实体类的方法不够灵活,很多时候里面的变量和参数都不固定,所以需要返回hashtable,用这个控件该怎么实现,网站的方法都找过了,全都是实体类的方法,
只看到一个用System.Runtime.Serialization.Formatters.Binary; 返回hashtable的,但是不能用 如下:
public static Hashtable evalJson(string Jsonstr)
{
using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(Jsonstr)))
{
BinaryFormatter bf = new BinaryFormatter();
return (Hashtable)bf.Deserialize(ms);
}
}