我無法用c#讀取json字符串。我在閱讀時遇到錯誤。用Newtonsoft C讀取Json字符串#
JSON文件
{
"Invoice": {
"Description": "New",
"InvoiceTypeId": "3d166468-3923-11e6-9e7c-40e230cfb8ae",
"CustomerAccountsId": "TEST",
"InvoiceDate": "2016-06-27",
"PayableDate": "2016-06-27",
"Prefix": "A",
"Serial": "34222",
"tag": "TEST"
},
"InvoiceLine": [
{
"ValueId": "c41d3d85-3a1e-11e6-9e7c-40e230cfb8ae",
"Qantity": "3",
"UnitId": "a72e0dde-3953-11e6-9e7c-40e230cfb8ae",
"Price": "1.500,00",
"VatRateId": "18",
"LineVat": "810,00",
"LineTotal": "5.310,00",
"Vat": "00a239f1-3c3a-11e6-9e7c-40e230cfb8ae"
},
{
"ValueId": "fd11b236-3952-11e6-9e7c-40e230cfb8ae",
"Qantity": "5",
"UnitId": "a72e0dde-3953-11e6-9e7c-40e230cfb8ae",
"Price": "1.000,00",
"VatRateId": "18",
"LineVat": "900,00",
"LineTotal": "5.900,00",
"Vat": "00a239f1-3c3a-11e6-9e7c-40e230cfb8ae"
}
]
}
「錯誤從JsonReader電流JsonReader項讀取JArray不是數組:。在StartObject路徑 '',第1行,位置1」。
JArray jsonVal = JArray.Parse(jsonArr) as JArray;
dynamic vars = jsonVal;
但是一切正常,我沒有看到錯誤。
你試圖反序列化一個不是數組的數組的json字符串。 –
我怎麼讀這個? – caras
創建您自己的類來反序列化此JSON字符串。 –