使用callbackWrapper函数解析.html页面的问题

时间:2018-03-11 04:52:55

标签: javascript json node.js

我试图在json结构中提取所有'id',如下所示:

callbackWrapper({

    "scoreboard": [
    {
        "day":"",
        "games":[
        {
             "id":"2433023",
             "lastUpdated":"1518108600",
             "updatedTimestamp":"2018-02-08 11:50:45",
             "conference":"all-conf southland northeast",
             "gameState":"final",
             "startDate":"2017-03-14",
             "startDateDisplay":"Mar. 14",
             "startTime":"6:40 PM ET",
             "startTimeEpoch":"1489531200",
             "currentPeriod":"",
             "finalMessage":"Final",
      etc....

我在nodejs js文件中有以下内容:

request({

    url: url,
    json: true

}, function (error, response, body) {

    try {

        var mmSchedule = body;

        console.log(mmSchedule) // PRINT THE PAGE CONTENTS

        for (var i = 0; i < body["scoreboard"]["games"].length; i++) {

            console.log("lenght: ", mmSchedule["scoreboard"]["games"].length); <--- DOESNT WORK!!!

        }

    }

}

我正试图在“记分牌” - “日” - “游戏”下阅读数组中的“id”,但我一直未定义!?

我错过了什么?

0 个答案:

没有答案