易采站长站为您分析C#中使用JSON.NET实现JSON、XML相互转换的相关代码及示例,需要的朋友可以参考下
官方 JSON.NET 地址
http://www.easck.com/pages/json-net.aspx
XML TO JSON
- string xml = @"<?xml version=""1.0"" standalone=""no""?> <root>
- <person id=""1""> <name>Alan</name>
- <url>http://www.easck.com/url> </person>
- <person id=""2""> <name>Louis</name>
- <url>http://www.easck.com/url> </person>
- </root>";
- XmlDocument doc = new XmlDocument(); doc.LoadXml(xml);
- string jsonText = JsonConvert.SerializeXmlNode(doc);
- //{ // "?xml": {
- // "@version": "1.0", // "@standalone": "no"
- // }, // "root": {
- // "person": [ // {
- // "@id": "1", // "name": "Alan",
- // "url": "http://www.easck.com// },
- // { // "@id": "2",
- // "name": "Louis", // "url": "http://www.easck.com// } // ]
- // } //}










