C# xml转实体对象

 

 

/// <summary>
        /// XML反序列化为对象
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="xml">xml字符串</param>
        /// <returns></returns>
        public static T Deserialize<T>(string xml)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
            StringReader stringReader = new StringReader(xml);
            return (T)xmlSerializer.Deserialize(stringReader);
        }

 

 

接口返回json格式

 

 

实体对应

 

 

 

 

 

参考地址:

https://www.cnblogs.com/youngharvard/p/8657484.html?ivk_sa=1024320u

https://www.cnblogs.com/Can-daydayup/p/16052873.html

https://www.cnblogs.com/Can-daydayup/p/16036872.html

https://www.cnblogs.com/wuyunblog/p/6625747.html

posted @ 2022-11-10 15:58  一介桃白白  阅读(804)  评论(0编辑  收藏  举报