【发布时间】:2018-09-18 07:47:31
【问题描述】:
我有以下 json 字符串:
{
"Orders": [{
"SubOrderNo": "0582715",
"ItemNo": "20415541",
"ItemType": "ART",
"ItemName": "Fish",
"TemplateName": "TP1234",
"ObjectType": "MPP",
"ObjectId": "PE1234",
"SalesStartDate": "2018-08-01",
"InfoText": "Some dummy text. This till be replaced later with some awesome text instead. Happy Fish!",
"Attachment": null,
"TemplateImage": null,
"ApprovedBy": "Me",
"ExpectedDeliveryDate": "2017-10-20",
"Context": null,
"TemplateDescription": null,
"ColorStatus": 0,
"spArticles": []
}],
"JsonOrders": null
}
我已经在 json lint 上验证了这个,所以它是有效的 json。
我有以下代码:
public static DataTable jsonStringToTable(string jsonContent)
{
DataTable dt = JsonConvert.DeserializeObject<DataTable>(jsonContent);
return dt;
}
当我运行它时,我得到了错误:
Unexpected JSON token when reading DataTable. Expected StartArray, got StartObject. Path '', line 1, position 1.
谁能告诉我为什么我不能将我的 json 转换为数据表?
【问题讨论】: