Json序列化、反序列化互换
// 序列化
using (MemoryStream stream = new MemoryStream())
{
serializer.WriteObject(stream, hdm);
jsonText = Encoding.UTF8.GetString(stream.ToArray());
//Console.WriteLine(jsonText);
}
// 反序列化
using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonText)))
{
DataContractJsonSerializer serializer1 = new DataContractJsonSerializer(typeof(AnesMS.DataModel.ByEntity._4Statistics.HISDataModel));
AnesMS.DataModel.ByEntity._4Statistics.HISDataModel hdm1 = (AnesMS.DataModel.ByEntity._4Statistics.HISDataModel)serializer1.ReadObject(ms);
return hdm1;
}