我通過ajax調用調用webservice,並在對其進行字符串化後將對象數組傳遞給它。Ajax + webservice +對象數組
數據字符串化後
data = '[{"para1":"pic 1","para2":"drop 1"},{"para1":"pic 2","para2":"drop 2"}]'
$.ajax({
type: 'POST',
url: "path to url/method",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
"data": data
}),
如何接受它,並在C#web服務解析。
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string insertroute(string data){
//how to parse data here
}
解析,可以很容易地實現與庫:http://stackoverflow.com/questions/4109807/parsing-json-data-with-c-sharp – 2015-03-31 18:36:11