gpt4 book ai didi

javascript - 不知道如何读取这个 json 格式

转载 作者:行者123 更新时间:2023-11-28 17:36:11 25 4
gpt4 key购买 nike

我从来没有遇到过从 url 或任何像这样构建的东西读取 json 的麻烦:

{ success: true,  name: 'Dekirai',  clan: null,  level: 7,  exp: 3193,  playtime: 0,  tdrate: 0,  kdrate: 0,  matches_played: 0,  matches_won: 0,  matches_lost: 0,  last_online: '2018-03-02T23:00:00.000Z',  views: 1,  favorites: 0,  fame: 0,  hate: 0 }

但是我现在拥有的 json 在内部使用方括号,如下所示:

[ { id: 23,    name: 'AeriaGames Login',    player_limit: -1,    player_online: -1,    state: 2,    last_update: '2018-02-14T16:22:28.000Z' },  { id: 1,    name: 'Auth',    player_limit: -1,    player_online: -1,    state: 2,    last_update: '2018-03-03T14:17:22.000Z' },  { id: 10,    name: 'English 1 (Europe)',    player_limit: 4000,    player_online: 871,    state: 2,    last_update: '2018-03-03T14:17:22.000Z' },  { id: 11,    name: 'English 2 (Europe)',    player_limit: 4000,    player_online: 48,    state: 2,    last_update: '2018-03-03T14:17:22.000Z' },  { id: 12,    name: 'English 3 (North America)',    player_limit: 4000,    player_online: 54,    state: 2,    last_update: '2018-03-03T14:17:22.000Z' } ]

我现在的问题是:

如何从“id: 10”读取“player_online”值?

最佳答案

let player_online = yourObject.find(el => el.id === 10).player_online

关于javascript - 不知道如何读取这个 json 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49085177/

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