这个是同事研究的wcf中中根据type类型反序列化json的示例

 /// <summary>
/// json转对象
/// </summary>
/// <param name="json"></param>
/// <param name="type"></param>
/// <returns></returns>
public static object DataContractJsonSerializer(string json, Type type)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(type);
MemoryStream mStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
return serializer.ReadObject(mStream);
}
05-11 16:21