How to convert JSON to XML or XML to JSON?

后端 未结 13 1299
借酒劲吻你
借酒劲吻你 2020-11-22 05:43

I started to use Json.NET to convert a string in JSON format to object or viceversa. I am not sure in the Json.NET framework, is it possible to convert a string in JSON to X

13条回答
  •  天涯浪人
    2020-11-22 06:07

    Thanks for David Brown's answer. In my case of JSON.Net 3.5, the convert methods are under the JsonConvert static class:

    XmlNode myXmlNode = JsonConvert.DeserializeXmlNode(myJsonString); // is node not note
    // or .DeserilizeXmlNode(myJsonString, "root"); // if myJsonString does not have a root
    string jsonString = JsonConvert.SerializeXmlNode(myXmlNode);
    

提交回复
热议问题