1
上的子值如何訪問「leaguePoints」?C#無法訪問Newtonsoft.Json.Linq.JValue
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]
,但在這兩種情況下它給我的錯誤
Cannot access child value on 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
}
]
}
]
}
我好蠢.-。非常感謝! – datboi
@datboi,不要忘了接受答案,如果它是正確的... –
如何檢查它是否存在[「層」],如果不切換,以檢查它是否存在[「條目」]? –