如何使用javascript解析JSON文件?

时间:2021-11-25 21:30:26

I'm trying to parse through the following JSON file using Javascript. Can somebody help me with how to retrieve the data from this kind of JSON structure?

我正在尝试使用Javascript解析以下JSON文件。有人可以帮助我如何从这种JSON结构中检索数据吗?

{
    "game_schedule": [
            {
                "day1":{
                    "date": "05/21/2016",
                    "time": ["09:06 am", "12:00 pm", "08:05 pm"],
                    "game": [
                        "SF Giants vs NY Mets",
                        "LA Dodgers vs SD Padres",
                        "SF Giants vs SD Padres"
                        ]
                },
                "day2":{
                    "date": "05/22/2016",
                    "time": ["09:06 am", "04:09 pm"],
                    "game": [
                        "LA Dodgers vs SF Gaints",
                        "LA Dodgers vs NY Mets"
                        ]

            }
        }
    ]  
}

1 个解决方案

#1


1  

var obj = JSON.parse( json_string );

// obj['game_schedule'][0]['day1']['date'] == '05/21/2016'

#1


1  

var obj = JSON.parse( json_string );

// obj['game_schedule'][0]['day1']['date'] == '05/21/2016'