Introduction
In this blog, we will learn how to convert JSON to XML and XML to JSON
JSON.NET
Json.NET is a popular high-performance JSON framework for .NET. We can do more with this as JSON.NET supports converting JSON to XML and vice versa, LINQ to JSON, Serializing and Deserialize JSON.
References
- http://www.newtonsoft.com/json/help/html/Introduction.htm
- https://json.codeplex.com/
How to install JSON.NET in Visual Studio Click on the “References” => Manage NuGet Packages
Click the Install Button.
Click OK. Now, the installation completes.
Another method to install is:
Click Tools=> NuGet Package Manager=> Package Manager Console.
Type “PM> Install-Package Newtonsoft.Json”.
DeserializeXmlNode() is the helper method to convert JSON to XML.
See the example, given below:
SerializeXmlNode() is another helper method used for converting XML to JSON.
See the example, given below:
Conclusion
In this blog, we learned to convert JSON to XML and XML to JSON with simple code.