I have a JSON structure like below.
(我有一个如下的JSON结构。)
json={
"page": {
"mode": "2",
"ref": "user"
}
}
I am using the following code for converting JSON to XML.
(我正在使用以下代码将JSON转换为XML。)
Reference: http://www.flowgearcoder.net/2013/04/03/convert-between-json-and-xml
(参考: http : //www.flowgearcoder.net/2013/04/03/convert-between-json-and-xml)
var dynamicObject = new System.Web.Script.Serialization.JavaScriptSerializer().DeserializeObject(Json);
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(dynamicObject.GetType());
MemoryStream ms = new MemoryStream();
serializer.Serialize(ms, dynamicObject);
Xml = System.Text.Encoding.UTF8.GetString(ms.ToArray());
I am getting the following error while executing the xmlSerializer conversion.
(执行xmlSerializer转换时出现以下错误。)
The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089], [System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.
(类型System.Collections.Generic.Dictionary`2 [[System.String,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089],[System.Object,mscorlib,Version = 2.0.0.0,Culture = neutral ,PublicKeyToken = b77a5c561934e089]不支持,因为它实现了IDictionary。)
Can anyone help me figure out this issue?
(谁能帮我解决这个问题?)
ask by Tom Cruise translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…