gpt4 book ai didi

javascript - 具有匹配值jquery js的对象属性

转载 作者:行者123 更新时间:2023-11-29 22:01:17 26 4
gpt4 key购买 nike

<分区>

我有一个 json 文件,其中包含玩家名称作为属性,值是 yes 和 no。每当 (Property = 'yes) 播放器播放时,我都尝试添加一个来计数。

这里是json文件的例子

{"Wojciech Szczesny":"yes","Lukasz Fabianski":"no","Emiliano Viviano":"no","Olivier Giroud":"yes","Per Mertesacker":"yes","Bacary Sagna":"yes","Laurent Koscielny":"no","Santi Cazorla":"yes","Mikel Arteta":"yes","Mesut \u00d6zil":"no","Kieran Gibbs":"yes","Aaron Ramsey":"no","Jack Wilshere":"no","Mathieu Flamini":"yes","Tomas Rosicky":"yes","Lukas Podolski":"yes","Nacho Monreal":"no","Theo Walcott":"no","Thomas Vermaelen":"yes","Carl Jenkinson":"no","Alex Oxlade-Chamberlain":"no","Serge Gnabry":"no","Kim Kallstrom":"no","Nicklas Bendtner":"no","Abou Diaby":"no","Park Chu-Young":"no","Emmanuel Frimpong":"no","Yaya Sanogo":"no","Ryo Miyaichi":"no","Hector Bellerin":"no","Chuba Akpom":"no","Isaac Hayden":"no","Gideon Zelalem":"no","Home":"home","Results":"draw"}

这是我的 Jquery 代码

var count = 0;
$.ajax({
url:'ars.json',
dataType:'json',
cache: true,
success: function(data) {
$(data).each(function(index, value){
if(Object.getOwnPropertyNames (value) == 'yes'){
count++;
}else{

}
});
console.log(count);
}

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