62,047
社区成员
发帖
与我相关
我的任务
分享
[Serializable]
public class ActLog
{
private int _logid=0;
private string _logcontent="";
private int _userid=0;
private string _usertype="";
private DateTime _addtime=DateTime.Now;
public int logid
{
get
{
return _logid;
}
set
{
_logid = value;
}
}
public string logcontent
{
get
{
return _logcontent;
}
set
{
_logcontent = value;
}
}
public int userid
{
get
{
return _userid;
}
set
{
_userid = value;
}
}
public string usertype
{
get
{
return _usertype;
}
set
{
_usertype = value;
}
}
public DateTime addtime
{
get
{
return _addtime;
}
set
{
_addtime = value;
}
}
}
public string test(string jsondata)
{
Model.ActLog userInfo = JSON.parse<Model.ActLog>(jsondata);
//logmodel userInfo = JSON.parse<logmodel>(jsondata);
return userInfo.logcontent;
}
public static T parse<T>(string jsonString)
{
T result;
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(jsonString)))
{
result = (T)((object)new DataContractJsonSerializer(typeof(T)).ReadObject(memoryStream));
}
return result;
}
a_user.a_UserSoapClient a1 = new a_user.a_UserSoapClient();
string json = "{";
json = json + "\"logid\":\"0\"";
json = json + ",\"logcontent\":\"" + TextBox1.Text + "\"";
json = json + ",\"userid\":\"1\"";
json = json + ",\"usertype\":\"用户类型\"";
//json = json + ",\"addtime\":\"2014-12-12 00:00:00\"";
json = json + "}";
Response.Write(a1.test(json));
public class ActLog
{
public int logid
{
get;
set;
}
public string logcontent
{
get;
set;
}
public int userid
{
get;
set;
}
public string usertype
{
get;
set;
}
public DateTime addtime
{
get;
set;
}
}
Model.ActLog userInfo = fastCSharp.emit.jsonParser.Parse<Model.ActLog>(jsondata);