C#_.Net Json转Xml

C#_.Net Json转Xml
 1     public  class XmlHelper
 2     {
 3         /// <summary>
 4         /// Json转Xml格式
 5         /// </summary>
 6         /// <param name="strJson"></param>
 7         /// <returns></returns>
 8         public static string JsonToXml(string strJson)
 9         {
10             string Xml = "";
11             XmlDictionaryReader reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(strJson), XmlDictionaryReaderQuotas.Max);
12             XmlDocument doc = new XmlDocument();
13             doc.Load(reader);
14             Xml = doc.InnerXml;
15             return Xml;
16         }
17     }
View Code
C#_.Net Json转Xml
 1         /// <summary>
 2         /// 获取用户 调用
 3         /// </summary>
 4         /// <param name="mid"></param>
 5         /// <returns></returns>
 6         [HttpGet]
 7         public IActionResult GetUserByLambda(string mid = "123")
 8         {
 9             var a = _userService.GetUsersByLambda(x => x.ManufacturerId.Equals(mid));
10             var c = JsonHelper.SerializeJSON(a);
11             var b = XmlHelper.JsonToXml(c);
12             return Ok(b);
13         }
View Code

 

结果

C#_.Net Json转Xml

 

C#_.Net Json转Xml

上一篇:delphi assigned


下一篇:SQL SERVER中CTE语句结构及CTE递归查询