我试图寻找此JSON代码找到统计:解析数据
{
"summonerId": 32033681,
"modifyDate": 1403658807000,
"champions": [{
"id": 40,
"stats": {
"totalSessionsPlayed": 1,
"totalSessionsLost": 0,
"totalSessionsWon": 1,
"totalChampionKills": 1,
"totalDamageDealt": 27006,
"totalDamageTaken": 9924,
"mostChampionKillsPerSession": 1,
"totalMinionKills": 17,
"totalDoubleKills": 0,
"totalTripleKills": 0,
"totalQuadraKills": 0,
"totalPentaKills": 0,
"totalUnrealKills": 0,
"totalDeathsPerSession": 2,
"totalGoldEarned": 8383,
"mostSpellsCast": 0,
"totalTurretsKilled": 2,
"totalPhysicalDamageDealt": 8957,
"totalMagicDamageDealt": 18049,
"totalFirstBlood": 0,
"totalAssists": 13,
"maxChampionsKilled": 1,
"maxNumDeaths": 2
}
},
{
"id": 36,
"stats": {
"totalSessionsPlayed": 1,
"totalSessionsLost": 1,
"totalSessionsWon": 0,
"totalChampionKills": 0,
"totalDamageDealt": 14267,
"totalDamageTaken": 7649,
"mostChampionKillsPerSession": 0,
"totalMinionKills": 33,
"totalDoubleKills": 0,
"totalTripleKills": 0,
"totalQuadraKills": 0,
"totalPentaKills": 0,
"totalUnrealKills": 0,
"totalDeathsPerSession": 5,
"totalGoldEarned": 3258,
"mostSpellsCast": 0,
"totalTurretsKilled": 0,
"totalPhysicalDamageDealt": 4992,
"totalMagicDamageDealt": 9165,
"totalFirstBlood": 0,
"totalAssists": 0,
"maxChampionsKilled": 0,
"maxNumDeaths": 5
}
}]
}
在下面的例子,我想成为totalSessionsWon能够搜索ID 36.我试着访问数据如何我已经从其他JSON文件访问数据,但它不允许我指定的冠军,我搜索的ID:
string jsonInput = new WebClient().DownloadString(@usableurl); //Reads the JSON from the API
string usableJson = @"JObject.Parse(jsonInput)"; //converts the JSON from the API to a usable form
var usableJson["champions"]["stats"]["totalSessionWon"];
有没有办法,我可以选择基于特定的统计信息的方式在它之前的id?
我是新来使用JSON和C#,所以你的帮助特别感谢!
你不能摆动一个死亡的负鼠在这里没有击中JSON的问题。阅读其中的一些内容,试试看,并在卡住时发布实际问题 – Plutonix
JSON的结构看起来很好。看起来您需要了解有关JSON的更多信息以及如何使用C#读取/写入它。如果您在网络上搜索该主题,可以找到关于该主题的大量教程。如果你只是在寻找教程,他们是关于堆栈溢出[关闭主题](http://stackoverflow.com/help/on-topic)。但是,如果您发布当前尝试的代码,那么我们可以帮助您找出所需数据出错的位置。 – Adrian
@Plutonix那个负鼠对你做了什么? –