【发布时间】:2020-08-14 23:56:36
【问题描述】:
Json 响应是这样的:
[
[
1597276800000,
"16.46340000",
"18.34880000",
"15.91750000",
"17.18830000",
"30941693.96000000",
1597363199999,
"527277033.75007300",
681520,
"15434492.74000000",
"263241680.21583200",
"0"
],
[
1597363200000,
"17.17280000",
"17.59980000",
"16.30000000",
"16.86580000",
"11130678.41000000",
1597449599999,
"188347963.49490200",
244865,
"5421845.98000000",
"91775690.92871400",
"0"
]
]
我知道这些属性的标签,但它们不在 json 文档中。 这就是响应在 json 查看器中的外观。 当我使用 json2csharp.com 进行转换时,我得到了这些:
public class Root {
public List<List<object>> MyArray { get; set; }
}
and
Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse);
编译器抱怨:
because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
列表列表或列表数组应该可以工作,但我不断收到相同的错误消息。
有什么想法吗?
谢谢
【问题讨论】:
标签: c# json deserialization