c语言json数组 查找字符串6,搜索匹配字符串的JSON数组,然后向上工作?

我想搜索匹配团队名称的数组,然后向上工作以获取整个匹配的数据,但我不确定如何这样做。 JSON数组如下所示:搜索匹配字符串的JSON数组,然后向上工作?

{

"name": "English Premier League 2016/17",

"rounds": [

{

"name": "Matchday 1",

"matches": [

{

"date": "2017-05-21",

"team1": {

"key": "swansea",

"name": "Swansea",

"code": "SWA"

},

"team2": {

"key": "westbrom",

"name": "West Bromwich Albion",

"code": "WBA"

},

"score1": 1,

"score2": 2

},

{

"date": "2017-05-21",

"team1": {

"key": "watford",

"name": "Watford",

"code": "WAT"

},

"team2": {

"key": "mancity",

"name": "Manchester City",

"code": "MCI"

},

"score1": 2,

"score2": 1

}

]

}

]

}

此刻,我的代码如下,但它说,它无法读取未定义的属性“TEAM1”。

var team = Swansea;

$.getJSON("https://raw.githubusercontent.com/opendatajson/football.json/master/2016-17/en.1.json", function(results) {

for(var i = 0; i < results.rounds.length; i++)

{

if(results.rounds[matchday].matches[i].team1.name == team)

{

console.log(results.rounds[matchday].matches.team1.name);

}

}

}

+0

(results.rounds [matchday] .matches [i] .team1.name == team)matchday分配给@Josh –

+0

Matchday是一个前面定义的var,用于帮助排序数据。在完整的一个(https://raw.githubusercontent.com/opendatajson/football.json/master/2016-17/en.1.json)中,每个球队出现了38次,所以我首先计算出哪个比赛日,然后是比赛日我为我想要的球队检查这个名字。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值