Tuesday, November 3, 2015

Conver JSON to XML

Following is the method to convert json to xml:

string ConvertToJson(string json)
{
    XmlDocument rootxml = new XmlDocument();
    XmlDocument doc;
    doc = JsonConvert.DeserializeXmlNode(json,"root");
    return doc.OuterXml;

}

For this we need to use newtonsoft.json dll to our project.
This dll can be installed by package manager. Perform following steps to download this package:

1. Go to Tools > Library Package Manager > Manage NuGet Packages for Solution...

2. Search for newtonsoft
3. Install Json.net

No comments:

Post a Comment