且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSON.Net-无法将当前json对象(例如{"name":"value"})反序列化为类型'system.collections.generic.list`1

更新时间:2021-10-22 08:33:44

在这种情况下,您应该向Deserializer请求 IDictionary<string, Match>

In this case, you should ask Deserializer for IDictionary<string, Match>

var mList= JsonConvert.DeserializeObject<IDictionary<string, Match>>(jsonstr);

第一个元素将具有键"40" ,其值将为Match实例

And the first element would have key "40" and the value will be the Match instance

换句话说,这部分:

"40": {
    "name": "Team A vs Team B",
    "value": {
      "home": 1,
      "away": 0
    }

将产生KeyValuePair:

will result in KeyValuePair:

key - "40"
value - Match { Name = "Team",  ... }