xml to json escaping

Aug 13, 2009 at 4:00 PM


I have a case when I need to convert xml to json, but getting double encoding and because of that invalid json. Am I doing something wrong?

Here is what I do:


 XmlDocument doc = new XmlDocument();

 doc.LoadXml(@"<name>O""Connor</name>"); // i use "" so it will be easier to see the  problem

string xDataJson = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);


the string I get


which is not parsable by json .






Aug 14, 2009 at 9:46 AM


I have the same problem. This seems to be a problem of javascriptserializer too.


Best wishes,



Aug 15, 2009 at 12:52 AM

I get this:


Something else is double encoding your JSON.