This project has moved and is read-only. For the latest updates, please go here.

Deserialize Json String to xml document

Nov 12, 2010 at 12:12 PM

Hi Guys

I have taken up a project to integration a .Net web app to a 3rd party system asset Management solution with an API that returns Json when I call a service.

I am having trouble getting the DeserialiseXmlNode method to work - I am not getting any XML returned when a pass in the Json string to the function, the xml document is empty

to add, I have tried passing through different Json strings, some much larger, and I do not get anything returned AT ALL, no a clue why.

any ideas guys?

Here's my code:

using Newtonsoft.Json;
using System.Xml;

namespace AssetManagementC
    public class JsonConvertor
        public XmlDocument Deserialize (string Json)
            XmlDocument xmldoc = (XmlDocument)JsonConvert.DeserializeXmlNode(Json);

            return xmldoc;



Here is the Json string I pass in, taken from here - DeserializeXMLNode

  ""?xml"": {
    ""@version"": ""1.0"",
    ""@standalone"": ""no""
  ""root"": {
    ""person"": [
        ""@id"": ""1"",
        ""name"": ""Alan"",
        ""url"": """"
        ""@id"": ""2"",
        ""name"": ""Louis"",
        ""url"": """"


Nov 12, 2010 at 2:47 PM

something else I have just spotted while running a test, exception:

Newtonsoft.Json.JsonSerializationException: XmlNodeConverter can only convert JSON that begins with an object.. 

Any ideas guys?