【发布时间】:2018-09-18 05:41:36
【问题描述】:
我正在尝试利用 Fortnite-api 来创建一个带有 Node.js 的 Discord 机器人。当我使用 Fortnite-api 中包含的方法来检索用户数据时,我收到了一个大对象,我在下面包含了它。我可以使用 JSON.Stringify() 将其转换为字符串,但这并不能真正帮助我访问这些数据的特定部分。我希望能够检索“solo”组或“duo”组等下的所有信息,并且也能够单独使用这些组下的密钥。
例如:soloWins = stats.group.solo.wins(或类似的东西)将返回“1”
感谢任何帮助!
{ group:
{ solo:
{ wins: 1,
top3: 0,
top5: 0,
top6: 0,
top10: 11,
top12: 0,
top25: 29,
'k/d': '0.95',
'win%': '0.01',
matches: 122,
kills: 115,
timePlayed: '14h 47m',
killsPerMatch: '0.94',
killsPerMin: '0.13' },
duo:
{ wins: 0,
top3: 0,
top5: 9,
top6: 0,
top10: 0,
top12: 18,
top25: 0,
'k/d': '1.25',
'win%': '0.00',
matches: 60,
kills: 75,
timePlayed: '7h 11m',
killsPerMatch: '1.25',
killsPerMin: '0.17' },
squad:
{ wins: 1,
top3: 12,
top5: 0,
top6: 16,
top10: 0,
top12: 0,
top25: 0,
'k/d': '1.43',
'win%': '0.02',
matches: 59,
kills: 83,
timePlayed: '9h 19m',
killsPerMatch: '1.41',
killsPerMin: '0.15' } },
info:
{ accountId: '6372c32ec81d4a0a9f6e79f0d5edc31a',
username: 'Mirardes',
platform: 'pc' },
lifetimeStats:
{ wins: 2,
top3s: 12,
top5s: 9,
top6s: 16,
top10s: 11,
top12s: 18,
top25s: 29,
'k/d': '1.14',
'win%': '0.01',
matches: 241,
kills: 273,
killsPerMin: '0.15',
timePlayed: '1d 7h 17m' }
}
}
【问题讨论】:
-
soloWins = stats.group.solo.wins应该可以工作,假设stats是对象的名称..?当你这样做时会发生什么? -
哇。这样可行。不知道我之前做错了什么...谢谢!!!
标签: javascript json node.js discord.js discord.io