如何访问深层嵌套的JSON对象中的项目?

时间:2013-10-05 15:57:15

标签: javascript arrays json html5 oop

Object
meta: Object
objects: Array[4]
    0: Object
    id: 19222
    leaguevine_url: "https://www.leaguevine.com/tournaments/19389/autumn-2013/pools/#19222"
    name: "D"
    resource_uri: "https://api.leaguevine.com/v1/pools/19222/"
    standings: Array[4]
        0: Object
        1: Object
        games_played: 0
        losses: 0
        plus_minus: 0
        points_allowed: 0
        points_scored: 0
        team: Object
        id: 21195
        leaguevine_url: "https://www.leaguevine.com/teams/21195/smokum/"
        name: "Smokum"
        resource_uri: "https://api.leaguevine.com/v1/teams/21195/"
        short_name: ""
        __proto__: Object
        team_id: 21195
        wins: 0
        __proto__: Object
        2: Object
        3: Object
            length: 4
    __proto__: Array[0]
    start_time: "2013-10-21T09:00:00+02:00"
    team_ids: Array[4]
    time_between_rounds: 120
    time_created: "2013-09-30T09:30:46.577758+00:00"
    time_last_updated: "2013-09-30T09:30:46.577791+00:00"
    tournament: Object
    tournament_id: 19389
    __proto__: Object
    1: Object
    2: Object
    3: Object

这些是我从Leaguevine API获得的JSON对象。如何访问团队名称“Smokum”?

除了使用Transparancy micro库将我的JSON对象呈现给我的HTML,但我不知道如何使用Javascript访问对象中的对象。

1 个答案:

答案 0 :(得分:0)

假设您发布的JSON为result,可以通过以下方式访问 属性值 Smokum

result.objects[0].standings[1].name