XML字符串反序列化为实体

 

JSON反序列化实体

paydata = StringHelper.Base64ToString(paydata);
resInfo = JsonConvert.DeserializeObject<RequestInfo>(paydata);

 

XMl反序列化实体

paydata = StringHelper.Base64ToString(paydata);
using (StringReader sr = new StringReader(paydata))
{

XmlSerializer xmlSerializer = string.IsNullOrWhiteSpace("xml") ?

new XmlSerializer(typeof(RequestInfo)) : new XmlSerializer(typeof(RequestInfo), new XmlRootAttribute("xml"));

resInfo = (RequestInfo)xmlSerializer.Deserialize(sr);
}

posted @ 2019-04-25 11:01  名叔  阅读(639)  评论(0编辑  收藏  举报