{"id":383,"date":"2015-06-28T21:53:52","date_gmt":"2015-06-28T13:53:52","guid":{"rendered":"http:\/\/39.100.100.179\/?p=383"},"modified":"2020-09-21T15:56:40","modified_gmt":"2020-09-21T07:56:40","slug":"c%e5%90%88%e6%88%90%e8%a7%a3%e6%9e%90xml%e4%b8%8ejson","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=383","title":{"rendered":"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON"},"content":{"rendered":"<p>\u5728\u7f51\u4e0a\u770b\u4e86\u770b\u5173\u4e8eJSON\u7684\u5408\u6210\u6559\u7a0b\uff0c\u89c9\u5f97\u8fd8\u662fmomo\u7684\u5bb9\u6613\u7406\u89e3\u4e9b\u3002\u540c\u6837\u4e5f\u611f\u8c22\u5176\u4ed6\u5206\u4eab\u7684\u540c\u76df\uff01<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff0000;\">\u5728\u6b64\u5949\u4e0a\u8f6c\u8f7d\u94fe\u63a5\uff1a<\/span><a href=\"http:\/\/www.xuanyusong.com\/archives\/1901\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.xuanyusong.com\/archives\/1901<\/a><\/p>\n<p style=\"text-align: left;\">\u00a0 \u00a0XML\u4e0eJSON\u5728\u5f00\u53d1\u4e2d\u975e\u5e38\u91cd\u8981\uff0c \u5176\u5b9e\u6838\u5fc3\u5c31\u662f\u5904\u7406\u5b57\u7b26\u4e32\u3002\u0013\u4e00\u4e2a\u662fXML\u7684\u5b57\u7b26\u4e32\u4e00\u4e2a\u662fJSON\u7684\u5b57\u7b26\u4e32\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u7f51\u7edc\u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u80af\u5b9a\u662f\u8981\u7528\u7684\u3002\u53e6\u5916\u73b0\u5728JSON\u975e\u5e38\u7684\u6d41\u884c\uff0c\u6211\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u878d\u5408\u4e86XML\u4e0eJSON\u7684\u5408\u6210\u4e0e\u89e3\u6790\uff0c\u5e0c\u671b\u5927\u5bb6\u559c\u6b22\uff01<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\"><img title=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" class=\"wp-image-2096 size-full aligncenter\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u53489.32.26-1.png\" alt=\"\" width=\"530\" height=\"344\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u53489.32.26-1.png 530w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u53489.32.26-1-300x195.png 300w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/p>\n<p style=\"text-align: left;\"><strong>\u9996\u5148\u6ce8\u610f\u5934\u6587\u4ef6\uff0cLitJson\u662f\u5904\u7406JSON\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u6700\u540e\u6211\u4f1a\u7ed9\u51fa\u4e0b\u8f7d\u5730\u5740\u3002<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">using UnityEngine;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Xml;\nusing System.IO;\nusing System.Text;\nusing LitJson;<\/pre>\n<p><strong>1\u3001\u751f\u6210XML<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void createXml()\n\t{\n               \/\/xml\u4fdd\u5b58\u7684\u8def\u5f84\uff0c\u8fd9\u91cc\u653e\u5728Assets\u8def\u5f84 \u6ce8\u610f\u8def\u5f84\u3002\n\t\tstring filepath = Application.dataPath + @\"\/my.xml\";\n               \/\/\u7ee7\u7eed\u5224\u65ad\u5f53\u524d\u8def\u5f84\u4e0b\u662f\u5426\u6709\u8be5\u6587\u4ef6\n\t\tif(!File.Exists (filepath))\n\t\t{\n                         \/\/\u521b\u5efaXML\u6587\u6863\u5b9e\u4f8b\n\t\t\t XmlDocument xmlDoc = new XmlDocument();\n                         \/\/\u521b\u5efaroot\u8282\u70b9\uff0c\u4e5f\u5c31\u662f\u6700\u4e0a\u4e00\u5c42\u8282\u70b9\n\t\t\t XmlElement root = xmlDoc.CreateElement(\"transforms\");\n                          \/\/\u7ee7\u7eed\u521b\u5efa\u4e0b\u4e00\u5c42\u8282\u70b9\n\t\t\t XmlElement elmNew = xmlDoc.CreateElement(\"rotation\");\n                        \/\/\u8bbe\u7f6e\u8282\u70b9\u7684\u4e24\u4e2a\u5c5e\u6027 ID \u548c NAME\n\t\t     elmNew.SetAttribute(\"id\",\"0\");\n \t\t     elmNew.SetAttribute(\"name\",\"momo\");\n\t\t       \/\/\u7ee7\u7eed\u521b\u5efa\u4e0b\u4e00\u5c42\u8282\u70b9\n        \t     XmlElement rotation_X = xmlDoc.CreateElement(\"x\");\n                     \/\/\u8bbe\u7f6e\u8282\u70b9\u4e2d\u7684\u6570\u503c\n                     rotation_X.InnerText = \"0\";\n                    XmlElement rotation_Y = xmlDoc.CreateElement(\"y\");\n                    rotation_Y.InnerText = \"1\";\n                    XmlElement rotation_Z = xmlDoc.CreateElement(\"z\");\n                     rotation_Z.InnerText = \"2\";\n                    \/\/\u8fd9\u91cc\u5728\u6dfb\u52a0\u4e00\u4e2a\u8282\u70b9\u5c5e\u6027\uff0c\u7528\u6765\u533a\u5206\u3002\u3002\n   \t\t   rotation_Z.SetAttribute(\"id\",\"1\");\n \n             \/\/\u628a\u8282\u70b9\u4e00\u5c42\u4e00\u5c42\u7684\u6dfb\u52a0\u81f3XMLDoc\u4e2d \uff0c\u8bf7\u4ed4\u7ec6\u770b\u5b83\u4eec\u4e4b\u95f4\u7684\u5148\u540e\u987a\u5e8f\uff0c\u8fd9\u5c06\u662f\u751f\u6210XML\u6587\u4ef6\u7684\u987a\u5e8f\n             elmNew.AppendChild(rotation_X);\n             elmNew.AppendChild(rotation_Y);\n             elmNew.AppendChild(rotation_Z);\n\t     root.AppendChild(elmNew);\n             xmlDoc.AppendChild(root);\n             \/\/\u628aXML\u6587\u4ef6\u4fdd\u5b58\u81f3\u672c\u5730\n             xmlDoc.Save(filepath);\n\t\t\t Debug.Log(\"createXml OK!\");\n\t\t}\n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">&lt;transforms&gt;\n  &lt;rotation id=\"0\" name=\"momo\"&gt;\n    &lt;x&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z id=\"1\"&gt;2&lt;\/z&gt;\n  &lt;\/rotation&gt;\n&lt;\/transforms&gt;<\/pre>\n<p><strong>2.\u66f4\u65b0XML\u6587\u4ef6<\/strong><\/p>\n<p><strong>\u4ee5\u5176\u4e2d\u67d0\u4e2a\u8282\u70b9\u540d\u79f0\u505a\u6761\u4ef6\uff0c\u5f53\u67e5\u8be2\u5230\u65f6\u66f4\u65b0\u8be5\u8282\u70b9<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void UpdateXml()\n\t{\n\t\tstring filepath = Application.dataPath + @\"\/my.xml\";\n\t\tif(File.Exists (filepath))\n\t\t{\n\t\t\t XmlDocument xmlDoc = new XmlDocument();\n                         \/\/\u6839\u636e\u8def\u5f84\u5c06XML\u8bfb\u53d6\u51fa\u6765\n\t\t\t xmlDoc.Load(filepath);\n                         \/\/\u5f97\u5230transforms\u4e0b\u7684\u6240\u6709\u5b50\u8282\u70b9\n\t\t\t XmlNodeList nodeList=xmlDoc.SelectSingleNode(\"transforms\").ChildNodes;\n                         \/\/\u904d\u5386\u6240\u6709\u5b50\u8282\u70b9\n\t\t\t foreach(XmlElement xe in nodeList)\n\t\t\t {\n                                \/\/\u62ff\u5230\u8282\u70b9\u4e2d\u5c5e\u6027ID =0\u7684\u8282\u70b9\n\t\t\t\tif(xe.GetAttribute(\"id\")==\"0\")\n\t\t\t\t{\n                                        \/\/\u66f4\u65b0\u8282\u70b9\u5c5e\u6027\n\t\t\t\t\txe.SetAttribute(\"id\",\"1000\");\n                                        \/\/\u7ee7\u7eed\u904d\u5386\n\t\t\t\t\tforeach(XmlElement x1 in xe.ChildNodes)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(x1.Name==\"z\")\n\t\t\t\t\t\t{\n                                                        \/\/\u8fd9\u91cc\u662f\u4fee\u6539\u8282\u70b9\u540d\u79f0\u5bf9\u5e94\u7684\u6570\u503c\uff0c\u800c\u4e0a\u9762\u7684\u62ff\u5230\u8282\u70b9\u8fde\u5e26\u7684\u5c5e\u6027\u3002\u3002\u3002\n\t\t\t\t\t\t\t x1.InnerText=\"update00000\";\n\t\t\t\t\t\t}\n \n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t }\n\t\t\t xmlDoc.Save(filepath);\n\t\t\t Debug.Log(\"UpdateXml OK!\");\n\t\t}\n \n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">&lt;transforms&gt;\n  &lt;rotation id=\"1000\" name=\"momo\"&gt;\n    &lt;x&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z id=\"1\"&gt;update00000&lt;\/z&gt;\n  &lt;\/rotation&gt;\n&lt;\/transforms&gt;<\/pre>\n<p><strong>3.\u6dfb\u52a0XML<\/strong><\/p>\n<p><strong>\u91cd\u590d\u7684\u5730\u65b9\u6211\u5c31\u4e0d\u89e3\u91ca\u62c9\u3002<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void AddXml()\n\t{\n\t\tstring filepath = Application.dataPath + @\"\/my.xml\";\n\t\tif(File.Exists (filepath))\n\t\t{\n\t\t\tXmlDocument xmlDoc = new XmlDocument();\n\t\t\txmlDoc.Load(filepath);\n\t\t\tXmlNode root = xmlDoc.SelectSingleNode(\"transforms\");\n\t\t\tXmlElement elmNew = xmlDoc.CreateElement(\"rotation\");\n\t\t\telmNew.SetAttribute(\"id\",\"1\");\n \t\t    elmNew.SetAttribute(\"name\",\"yusong\");\n \n        \t XmlElement rotation_X = xmlDoc.CreateElement(\"x\");\n             rotation_X.InnerText = \"0\";\n\t\t\t rotation_X.SetAttribute(\"id\",\"1\");\n             XmlElement rotation_Y = xmlDoc.CreateElement(\"y\");\n             rotation_Y.InnerText = \"1\";\n             XmlElement rotation_Z = xmlDoc.CreateElement(\"z\");\n             rotation_Z.InnerText = \"2\"; \n \n             elmNew.AppendChild(rotation_X);\n             elmNew.AppendChild(rotation_Y);\n             elmNew.AppendChild(rotation_Z);\n\t\t\t root.AppendChild(elmNew);\n             xmlDoc.AppendChild(root);\n             xmlDoc.Save(filepath);\n\t\t\t Debug.Log(\"AddXml OK!\");\n\t\t}\n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">&lt;transforms&gt;\n  &lt;rotation id=\"1000\" name=\"momo\"&gt;\n    &lt;x&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z id=\"1\"&gt;update00000&lt;\/z&gt;\n  &lt;\/rotation&gt;\n  &lt;rotation id=\"1\" name=\"yusong\"&gt;\n    &lt;x id=\"1\"&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z&gt;2&lt;\/z&gt;\n  &lt;\/rotation&gt;\n&lt;\/transforms&gt;<\/pre>\n<p><strong>4.\u5220\u9664XML<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void deleteXml()\n\t{\n\t\tstring filepath = Application.dataPath + @\"\/my.xml\";\n\t\tif(File.Exists (filepath))\n\t\t{\n\t\t\t XmlDocument xmlDoc = new XmlDocument();\n\t\t\t xmlDoc.Load(filepath);\n\t\t\t XmlNodeList nodeList=xmlDoc.SelectSingleNode(\"transforms\").ChildNodes;\n\t\t\t foreach(XmlElement xe in nodeList)\n\t\t\t {\n\t\t\t\tif(xe.GetAttribute(\"id\")==\"1\")\n\t\t\t\t{\n\t\t\t\t\txe.RemoveAttribute(\"id\");\n\t\t\t\t}\n \n\t\t\t\tforeach(XmlElement x1 in xe.ChildNodes)\n\t\t\t\t{\n\t\t\t\t\tif(x1.Name == \"z\")\n\t\t\t\t\t{\n\t\t\t\t\t\tx1.RemoveAll();\n \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t }\n\t\t\t xmlDoc.Save(filepath);\n\t\t\t Debug.Log(\"deleteXml OK!\");\n\t\t}\n \n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">&lt;transforms&gt;\n  &lt;rotation id=\"1000\" name=\"momo\"&gt;\n    &lt;x&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z&gt;\n    &lt;\/z&gt;\n  &lt;\/rotation&gt;\n  &lt;rotation name=\"yusong\"&gt;\n    &lt;x id=\"1\"&gt;0&lt;\/x&gt;\n    &lt;y&gt;1&lt;\/y&gt;\n    &lt;z&gt;\n    &lt;\/z&gt;\n  &lt;\/rotation&gt;\n&lt;\/transforms&gt;<\/pre>\n<p><strong>4.\u89e3\u6790\u4e0e\u8f93\u51fa\u4e0a\u9762\u7684XML<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void showXml()\n\t{\n\t\tstring filepath = Application.dataPath + @\"\/my.xml\";\n\t\tif(File.Exists (filepath))\n\t\t{\n\t\t\t XmlDocument xmlDoc = new XmlDocument();\n\t\t\t xmlDoc.Load(filepath);\n\t\t\t XmlNodeList nodeList=xmlDoc.SelectSingleNode(\"transforms\").ChildNodes;\n\t\t\t\/\/\u904d\u5386\u6bcf\u4e00\u4e2a\u8282\u70b9\uff0c\u62ff\u8282\u70b9\u7684\u5c5e\u6027\u4ee5\u53ca\u8282\u70b9\u7684\u5185\u5bb9\n\t\t\t foreach(XmlElement xe in nodeList)\n\t\t\t {\n\t\t\t\tDebug.Log(\"Attribute :\" + xe.GetAttribute(\"name\"));\n\t\t\t\tDebug.Log(\"NAME :\" + xe.Name);\n\t\t\t\tforeach(XmlElement x1 in xe.ChildNodes)\n\t\t\t\t{\n\t\t\t\t\tif(x1.Name == \"y\")\n\t\t\t\t\t{\n\t\t\t\t\t\tDebug.Log(\"VALUE :\" + x1.InnerText);\n \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t }\n\t\t\t Debug.Log(\"all = \" + xmlDoc.OuterXml);\n \n\t\t}\n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c\uff08\u70b9\u51fb\u56fe\u7247\u6700\u5927\u5316\uff09<\/strong><\/p>\n<p style=\"text-align: left;\"><img title=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" class=\"wp-image-2097 size-full aligncenter\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.18.42-1.png\" alt=\"\" width=\"1160\" height=\"284\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.18.42-1.png 1160w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.18.42-1-300x73.png 300w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.18.42-1-1024x251.png 1024w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.18.42-1-768x188.png 768w\" sizes=\"(max-width: 1160px) 100vw, 1160px\" \/><\/p>\n<p><strong>\u63a5\u7740\u662f\u5904\u7406JSON<\/strong><\/p>\n<p><strong>5.\u89e3\u6790JSON\u5b57\u7b26\u4e32\u663e\u793a\u5b57\u5178\u952e\u503c<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void ResolveJson()\n\t{\n                 \/\/\u5b9a\u4e49\u7684JSON\u5b57\u7b26\u4e32\uff0c\u6ce8\u610fJSON\u7684\u683c\u5f0f\n\t\t string str = @\"\n            {\n                \"\"Name\"\"     : \"\"yusong\"\",\n                \"\"Age\"\"      : 26,\n                \"\"Birthday\"\" : \"\"1986-11-21\"\",\n \t\t\t\t\"\"Thumbnail\"\":[\n\t\t\t\t{\n           \t\t\t\"\"Url\"\":    \"\"http:\/\/xuanyusong.com\"\",\n           \t\t\t\"\"Height\"\": 256,\n           \t\t\t\"\"Width\"\":  \"\"200\"\"\n\t\t\t\t},\n\t\t\t\t{\n           \t\t\t\"\"Url\"\":    \"\"http:\/\/baidu.com\"\",\n           \t\t\t\"\"Height\"\": 1024,\n           \t\t\t\"\"Width\"\":  \"\"500\"\"\n\t\t\t\t}\n \n\t\t\t\t]\n            }\";\n\t\t\/\/\u8fd9\u91cc\u662f\u89e3\u6790\uff0c\u5305\u62ec\u6574\u5f62\u4e0e\u5b57\u7b26\u4e32\n\t\tJsonData jd = JsonMapper.ToObject(str);\n\t\tDebug.Log(\"name = \" + (string)jd[\"Name\"]);\n\t\tDebug.Log(\"Age = \" + (int)jd[\"Age\"]);\n\t\tDebug.Log(\"Birthday = \" + (string)jd[\"Birthday\"]);\n\t\tJsonData jdItems = jd[\"Thumbnail\"]; \n \n\t\tfor (int i = 0; i &lt; jdItems.Count; i++)\n\t\t{\n\t\t\tDebug.Log(\"URL = \" + jdItems[i][\"Url\"]);\n\t\t\tDebug.Log(\"Height = \" + (int)jdItems[i][\"Height\"]);\n        \tDebug.Log(\"Width = \" + jdItems[i][\"Width\"]);\n\t\t}\n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<p style=\"text-align: left;\"><img title=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c3\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c3\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" class=\"wp-image-2099 size-full aligncenter\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.28.43-1.png\" alt=\"\" width=\"265\" height=\"354\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.28.43-1.png 265w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.28.43-1-225x300.png 225w\" sizes=\"(max-width: 265px) 100vw, 265px\" \/><\/p>\n<p style=\"text-align: left;\"><strong>6.\u5408\u6210JSON\u5b57\u7b26\u4e32\uff0c\u5148\u5408\u6210 \u7136\u540e\u5728\u8f93\u51fa\u3002<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">\tpublic void MergerJson()\n\t{\n\t\tStringBuilder sb = new StringBuilder ();\n        JsonWriter writer = new JsonWriter (sb);\n \n        writer.WriteObjectStart ();\n \n\t\twriter.WritePropertyName (\"Name\");\n        writer.Write (\"yusong\");\n \n\t\twriter.WritePropertyName (\"Age\");\n        writer.Write (26);\n \n\t\twriter.WritePropertyName (\"Girl\");\n \n\t\twriter.WriteArrayStart ();\n \n\t\twriter.WriteObjectStart();\n\t\twriter.WritePropertyName(\"name\");\n        writer.Write(\"ruoruo\");\n        writer.WritePropertyName(\"age\");\n        writer.Write(24);\n\t\twriter.WriteObjectEnd ();\n \n\t\twriter.WriteObjectStart();\n\t\twriter.WritePropertyName(\"name\");\n        writer.Write(\"momo\");\n        writer.WritePropertyName(\"age\");\n        writer.Write(26);\n\t\twriter.WriteObjectEnd ();\n \n\t\twriter.WriteArrayEnd();\n \n\t\twriter.WriteObjectEnd ();\n\t\tDebug.Log(sb.ToString ());\n \n\t\tJsonData jd = JsonMapper.ToObject(sb.ToString ());\n\t\tDebug.Log(\"name = \" + (string)jd[\"Name\"]);\n\t\tDebug.Log(\"Age = \" + (int)jd[\"Age\"]);\n\t\tJsonData jdItems = jd[\"Girl\"];\n\t\tfor (int i = 0; i &lt; jdItems.Count; i++)\n\t\t{\n\t\t\tDebug.Log(\"Girl name = \" + jdItems[i][\"name\"]);\n\t\t\tDebug.Log(\"Girl age = \" + (int)jdItems[i][\"age\"]);\n\t\t}\n\t}<\/pre>\n<p><strong>\u8fd0\u884c\u7ed3\u679c<\/strong><\/p>\n<p style=\"text-align: left;\"><img title=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c4\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u4f7f\u7528 C#\u5408\u6210\u89e3\u6790XML\u4e0eJSON - \u7b2c4\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" class=\"wp-image-2100 size-full aligncenter\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.33.45-1.png\" alt=\"\" width=\"518\" height=\"288\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.33.45-1.png 518w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/06\/\u5c4f\u5e55\u5feb\u7167-2012-11-29-\u4e0b\u534810.33.45-1-300x167.png 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\"><strong>\u5de5\u7a0b\u4e0b\u8f7d\uff1a<a href=\"http:\/\/vdisk.weibo.com\/s\/jkBml\">\u00a0http:\/\/vdisk.weibo.com\/s\/jkBml<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7f51\u4e0a\u770b\u4e86\u770b\u5173\u4e8eJSON\u7684\u5408\u6210\u6559\u7a0b\uff0c\u89c9\u5f97\u8fd8\u662fmomo\u7684\u5bb9\u6613\u7406\u89e3\u4e9b\u3002\u540c\u6837\u4e5f\u611f\u8c22\u5176\u4ed6 &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=383\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[118,119],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/383"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":4,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":2101,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/2101"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}