//后台返回json
List<ClassName> classList = new List<ClassName>();
DataTable tb1 = getData();
string tb1Result = JsonConvert.SerializeObject(tb1);
string classResult = JsonConvert.SerializeObject(classList);
classResult = "\"class\":" + classResult;
tb1Result = "\"tb1\":" + tb1Result;
string result = "{" + classResult + "," + tb1Result + "}";
context.Response.ContentType = "application/json";
context.Response.Write(result);
//后台得到json
System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream);
String datajason = HttpUtility.UrlDecode(reader.ReadToEnd());
DataTable tableClient = JsonConvert.DeserializeObject<DataTable>(datajason);//datatable or ClassName
c#处理json
最新推荐文章于 2024-05-05 16:31:47 发布