gpt4 book ai didi

C# 无法访问 Newtonsoft.Json.Linq.JValue 上的子值

转载 作者:行者123 更新时间:2023-12-01 09:52:54 25 4
gpt4 key购买 nike

我将如何访问“leaguePoints”?

    using (var http = new HttpClient())
{
var result = JObject.Parse(await http.GetStringAsync($"https://euw.api.riotgames.com/api/lol/EUW/v2.5/league/by-summoner/12345678/entry?api_key=" + apikey).ConfigureAwait(false));
var something = (Uri.EscapeUriString(result["12345678"][0]["tier"]["leaguePoints"].ToString()));
}

我也尝试在 ["tier"] 之后添加一个 [0],但在这两种情况下都会出现错误

无法访问 Newtonsoft.Json.Linq.JValue 上的子值。

Json 示例响应如下:

{
"12345678": [
{
"tier": "PLATINUM",
"queue": "RANKED_SOLO_5x5",
"name": "Taric's Templars",
"entries": [
{
"isFreshBlood": false,
"division": "III",
"isVeteran": false,
"wins": 9,
"losses": 1,
"playerOrTeamId": "12345678",
"playerOrTeamName": "noname123",
"isInactive": false,
"isHotStreak": false,
"leaguePoints": 0
}
]
}
]
}

最佳答案

“leaguePoints”似乎在“条目”而不是“层”中:

 result["12345678"][0]["entries"][0]["leaguePoints"]

关于C# 无法访问 Newtonsoft.Json.Linq.JValue 上的子值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43161432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com