내가 코드를 테스트하고 나를 위해 완전히 잘 작동 : 여기
내가 가진 것입니다. 이것은 확실히해야 DeserializeXmlNode
에 대한 설명서에 따라 작동 :
// { "?xml": { "@version": "1.0", "@standalone": "no" }, "root": { "person": [ { "@id": "1", "name": "Alan", "url": "http://www.google.com" }, { "@id": "2", "name": "Louis", "url": "http://www.yahoo.com" } ] } }
string json = "{ \"?xml\": { \"@version\": \"1.0\", \"@standalone\": \"no\" }, \"root\": { \"person\": [ { \"@id\": \"1\", \"name\": \"Alan\", \"url\": \"http://www.google.com\" }, { \"@id\": \"2\", \"name\": \"Louis\", \"url\": \"http://www.yahoo.com\" } ] } }";
System.Xml.XmlDocument xmlDocument = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(json);
System.Xml.XmlTextWriter xmlTextWriter = new System.Xml.XmlTextWriter("json.xml", null);
xmlTextWriter.Formatting = System.Xml.Formatting.Indented;
xmlDocument.Save(xmlTextWriter);
//<?xml version="1.0" standalone="no"?>
//<root>
// <person id="1">
// <name>Alan</name>
// <url>http://www.google.com</url>
// </person>
// <person id="2">
// <name>Louis</name>
// <url>http://www.yahoo.com</url>
// </person>
//</root>
가 작동하는지 확인하기 위해, 위의 JSON 문자열로 당신의 방법을 테스트합니다. 귀하의 JSON에 문제가있는 것 같아요.
여기 예를 들어 당신의 JSON 유효성을 검사 할 수 있습니다 : 무엇을 작동하지
? 오류가 있습니까? 예외? – Oded
한 가지 예외가 있습니다. 'Newtonsoft.Json.JsonSerializationException '유형의 첫 번째 예외는 Newtonsoft.Json.Net35.dll'에서 발생했습니다. – user556396
즉,'Json.NET'에 의해 잡히고 처리되었습니다. 아직도 작동하지 않는 것을 설명하지 않았습니다. – Oded