我有数组需要将该数组传递给我的 ASP.Net Webservice
我的数组如下所示:
{
"lists" [
{"F0":"LpSeries", "F1":"Description"},
{"F0":"Second","F1":"StringValue"}
]
}
我使用这样的javascript:
$.ajax({
type: "POST",
contentType: "application/json",
data: jsonText,
url: "LPService.asmx/GetDataTableFromArray",
dataType: "json",
success: function (data) {
alert(data.d);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
在网络服务中,我这样写
[WebInvoke(Method = "POST", UriTemplate = "")]
public DataTable X(RootObject root)
{
DataTable dt = new DataTable();
return dt;
// do something with your root objects or its child objects...
//return new HttpResponseMessage(HttpStatusCode.Created);
}
在这里,我为根对象创建了一个类,它看起来像这样
public class RootObject
{
public List<Result> Results { get; set; }
}
public class Result
{
public string F0 { get; set; }
public string F1 { get; set; }
public string F2 { get; set; }
public string F3 { get; set; }
public string F4 { get; set; }
public string F5 { get; set; }
public string F6 { get; set; }
public string F7 { get; set; }
}
我无法获得价值。请帮我解决这个问题