我通过 AJAX 和 Web Api 将 JSON 对象发送到我的服务器:
var data = [
["fdsfsd", "Kifdsfa", "fsdfsa", "fadsf", "fasdfsd", "fadsf", "fasdfsd"],
["2008", "-5", "11", "12", "13"],
["2009", "20", "-11", "14", "13"],
["2010", "30", "15", "-12", "readOnly"]
];
$.ajax({
url: '../webapi/Products',
type: 'POST',
dataType: "text",
data: "="+JSON.stringify( data ),
success: function (test) {
alert(test);
},
error: function (test) {
alert("Error");
}
所以我在服务器上获取我想用 JSON.NET 解析的值:
public void Post([FromBody]string value )
{
JObject o = JObject.Parse(@value);
}
这会引发异常:
Error reading JObject from JsonReader. Current JsonReader item is not an object:
StartArray. Path '', line 1, position 1.
为什么?这个价值似乎对我来说是正确的?