C# 后台接收Json对象并赋值到类对象

//获取http通过post传来的json数据
var request = System.Web.HttpContext.Current.Request;
byte[] requestData = new byte[request.InputStream.Length];
request.InputStream.Read(requestData,0,(int)request.InputStream.Length);
string json = Encoding.UTF8.GetString(requestData);

//Jsonstr函数读取json数据的文本txt
//string json = ClassLibrary01.User01.Jsonstr("D:\\Json.txt");

//实例化一个能够序列化数据的类
JavaScriptSerializer js = new JavaScriptSerializer();

//将json数据转化为对象类型并赋值给user
ClassLibrary01.User01.User user = js.Deserialize<ClassLibrary01.User01.User>(json);

上一篇:streama和string转换


下一篇:InnoDB数据库 ibdata1 被删除后 的恢复方法