【发布时间】:2020-12-07 22:42:40
【问题描述】:
我得到空值反序列化对象。试图删除该 List 关键字,但后来我得到空值。错误-
Cannot deserialize the current JSON object
`
也许您有任何解决方法的想法。 :)
代码:
client.BaseAddress = new Uri("https://euw1.api.riotgames.com/lol/match/v4/matchlists/by-account/");
string s = client.GetStringAsync("SRAUZPYTqglRgTjMEzaqY1s-wFMaNZnCjgBHMqQNDnJeJNw?endIndex=10&api_key=RGAPI-7bc6b22c-3ce3-41e6-bfbd-90b1eccb212f").Result;
var rankInfoList = JsonConvert.DeserializeObject<List<MatchInfo>>(s);
型号:
public class MatchInfo
{
public string gameId { get; set; }
public string champion { get; set; }
}
json:
{
"matches": [
{
"platformId": "EUW1",
"gameId": 4961339963,
"champion": 1,
"queue": 420,
"season": 13,
"timestamp": 1607031715226,
"role": "SOLO",
"lane": "MID"
},
{
"platformId": "EUW1",
"gameId": 4961185949,
"champion": 238,
"queue": 420,
"season": 13,
"timestamp": 1607026682284,
"role": "SOLO",
"lane": "MID"
}
],
"startIndex": 0,
"endIndex": 2,
"totalGames": 120
}
【问题讨论】: