C# json object互转工具

public static T Deserializer<T>(string path)
        {
            try
            {
                System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
                xd.LoadXml(path);
                MemoryStream stream = new MemoryStream();
                xd.Save(stream);

                XmlSerializer xml = new XmlSerializer(typeof(T));
                //序列化对象
                T t = (T)xml.Deserialize(stream);
                stream.Close();
                return t;
            }
            catch (InvalidOperationException)
            {
                throw;
            }
            catch (FileNotFoundException)
            { throw; }
            finally
            {

            }
        }

https://jsonclassgenerator.codeplex.com/

http://json2csharp.com/

原文地址:https://www.cnblogs.com/fumj/p/3397510.html