How to convert JSON to XML or XML to JSON?

后端 未结 13 1073
借酒劲吻你
借酒劲吻你 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:23

    Here is a simple snippet that converts a XmlNode (recursively) into a hashtable, and groups multiple instances of the same child into an array (as an ArrayList). The Hashtable is usually accepted to convert into JSON by most of the JSON libraries.

    protected object convert(XmlNode root){
        Hashtable obj = new Hashtable();
        for(int i=0,n=root.ChildNodes.Count;i

提交回复
热议问题