尝试
data: JSON.stringify([{id: "10000", name: "bill"},{id: "10005", name: "paul"}])
另外,JSON字符串需要以其他方式读取
string jsonString = String.Empty;HttpContext.Current.Request.InputStream.Position = 0;using (StreamReader inputStream = new StreamReader(HttpContext.Current.Request.InputStream)){ jsonString = inputStream.ReadToEnd();}
一个可行的解决方案
public void ProcessRequest(HttpContext context){ var jsonSerializer = new JavascriptSerializer(); var jsonString = String.Empty; context.Request.InputStream.Position = 0; using (var inputStream = new StreamReader(context.Request.InputStream)) { jsonString = inputStream.ReadToEnd(); } var emplList = jsonSerializer.Deserialize<List<Employee>>(jsonString); var resp = String.Empty; foreach (var emp in emplList) { resp += emp.name + " \ "; } context.Response.ContentType = "application/json"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(jsonSerializer.Serialize(resp));}public class Employee{ public string id { get; set; } public string name { get; set; }}public bool IsReusable{ get { return false; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)