我正在尝试将以下数据反序列化为DataSet (我相信DataSet是正确的选择?)。当我的数据 属性具有甚至列数时,它可以正常工作,但是当我有奇数列数时抛出:Additional text found in JSON string after finishing deserializing object.
请求反序列化:
Stream inputStream = controllerContext.HttpContext.Request.InputStream;
inputStream.Position = 0;
String json = new StreamReader(inputStream).ReadToEnd();
inputStream.Close();
System.Data.DataSet dataSet = null;
dataSet = JsonConvert.DeserializeObject<System.Data.DataSet>(json);
模拟数据:
var valid =
{
"colHeaders": [
{ "text": "TestHeader1", "influence": 1, "weight": 20.5 },
{ "text": "TestHeader2", "influence": 0, "weight": 30 }
],
"rowHeaders": [
{ "text": "RowHeader1" },
{ "text": "RowHeader2" }
],
"data": [
["data_00", "data_01"],
["data_10", "data_11"]
]
}
var not_valid =
{
"colHeaders": [
{ "text": "TestHeader1", "influence": 1, "weight": 20.5 }
],
"rowHeaders": [
{ "text": "RowHeader1" },
{ "text": "RowHeader2" }
],
"data": [
["data_00"],
["data_10"]
]
}