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);
标签:ClassLibrary01,C#,request,json,InputStream,requestData,对象,Json 来源: https://www.cnblogs.com/BaYueGua/p/15543961.html