【发布时间】:2016-11-19 20:22:12
【问题描述】:
我在尝试反序列化 JSON 文本时收到以下错误:
解析值时遇到意外字符:{。路径“[0]”,第 1 行,位置 3。
使用 JSONLint.com 正确验证的 JSON 文本,这里是 JSON 文本:
[
[
{"trackingNo":"R2E2003100011429","eventTime":1479184076000,"eventCode":"INF","activity":"Shipping Information received by Australia Post","location":"","referenceTrackingNo":null},
{"trackingNo":"R2E2003100011429","eventTime":1479186149000,"eventCode":"INF","activity":"Shipping Information approved by Australia Post","location":"","referenceTrackingNo":null},
{"trackingNo":"R2E2003100011429","eventTime":1479448620000,"eventCode":"SCN","activity":"Departed facility","location":"","referenceTrackingNo":null}
],
[
{"trackingNo":"HBF0003142011420","eventTime":1478666798000,"eventCode":"INF","activity":"Shipping Information received by Australia Post","location":"","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1478732453000,"eventCode":"INF","activity":"Shipping Information approved by Australia Post","location":"","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1478932980000,"eventCode":"SCN","activity":"Departed facility","location":"","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1479082255000,"eventCode":"SCN","activity":"Arrived at facility in destination country","location":"","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1479082261000,"eventCode":"CCD","activity":"Cleared by customs","location":"","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1479124118000,"eventCode":"SCN","activity":"Processed through Australia Post facility","location":"CHULLORA NSW","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1479236805000,"eventCode":"SCN","activity":"With Australia Post for delivery today","location":"KINGSGROVE NSW","referenceTrackingNo":null},
{"trackingNo":"HBF0003142011420","eventTime":1479248135000,"eventCode":"DLD","activity":"Delivered","location":"CARINGBAH NSW","referenceTrackingNo":null}
]
]
Here is my code:
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
string text = reader.ReadToEnd();
List<string[]> trackingResponse = JsonConvert.DeserializeObject<List<string[]>>(text);
// ...Do some stuff...
}
【问题讨论】: