日期:2014-05-17 浏览次数:20818 次
以下是示例请求 Json 正文:
{
"Equip_ID":2147483647,
"ID":2147483647,
"KeyCode":"字符串内容",
"Operator":"字符串内容",
"RefreshTime":"\/Date(928120800000+0800)\/",
"YNNotAllowedToEnter":"字符串内容",
"YNOpenPeriodOfTime":"字符串内容",
"YNUnclosedAlarm":"字符串内容"
}
+ RefreshTime {1999/5/31 11:20:00} System.DateTime
public static string Serialize<T>(T obj)
{
if (obj == null) return string.Empty;
using (MemoryStream stream = new MemoryStream())
{
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
XmlSerializer slz = new XmlSerializer(obj.GetType());
slz.Serialize(stream, obj, ns);
byte[] buf = stream.ToArray();
return Encoding.UTF8.GetString(buf, 0, buf.Length).Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n", "");
}
}