[
{
"cid": "1",
"course_name": "CS",
"subcode": "CS-601",
"subname": "Microprocessor",
"semester": "6"
},
{
"cid": "2",
"course_name": "CS",
"subcode": "CS-602",
"subname": "PPL",
"semester": "6"
},
{
"cid": "3",
"course_name": "CS",
"subcode": "CS-604",
"subname": "computer networking",
"semester": "6"
},
{
"cid": "4",
"course_name": "CS",
"subcode": "CS-603",
"subname": "software Engineering",
"semester": "6"
},
{
"cid": "5",
"course_name": "CS",
"subcode": "CS-601[P]",
"subname": "Microprocessor practical",
"semester": "6"
},
{
"cid": "6",
"course_name": "CS",
"subcode": "CS-604[P]",
"subname": "Computer networking practical",
"semester": "6"
},
{
"cid": "22",
"course_name": "ME",
"subcode": "ME-301",
"subname": "motar",
"semester": "3"
},
{
"cid": "23",
"course_name": "ME",
"subcode": "ME-302",
"subname": "friction",
"semester": "3"
},
{
"cid": "24",
"course_name": "ME",
"subcode": "ME-301[P]",
"subname": "motar practical",
"semester": "3"
},
{
"cid": "25",
"course_name": "ME",
"subcode": "ME-302[P]",
"subname": "friction practical",
"semester": "3"
},
{
"cid": "26",
"course_name": "CE",
"subcode": "CE-701",
"subname": "Design of hydraulic Structure",
"semester": "7"
},
{
"cid": "27",
"course_name": "CE",
"subcode": "CE-702",
"subname": "Advances Structrued design 2",
"semester": "7"
},
{
"cid": "28",
"course_name": "CE",
"subcode": "CE-701[P]",
"subname": "Design of hydraulic Structure practical",
"semester": "7"
},
{
"cid": "29",
"course_name": "CE",
"subcode": "CE-702[P]",
"subname": "Advances Structrued design 2 practical",
"semester": "7"
},
{
"cid": "45",
"course_name": "AU",
"subcode": "AU-502",
"subname": "AUTOMATION TOOL",
"semester": "1"
}
]
答案 0 :(得分:-1)
我会向你展示我的想法。希望这些可以帮到你。来自中国。
var arr = [{"cid":"1","course_name":"CS","subcode":"CS-601","subname":"Microprocessor","semester":"6"},{"cid":"2","course_name":"CS","subcode":"CS-602","subname":"PPL","semester":"6"},{"cid":"3","course_name":"CS","subcode":"CS-604","subname":"computer networking","semester":"6"},{"cid":"4","course_name":"CS","subcode":"CS-603","subname":"software Engineering","semester":"6"},{"cid":"5","course_name":"CS","subcode":"CS-601[P]","subname":"Microprocessor practical","semester":"6"},{"cid":"6","course_name":"CS","subcode":"CS-604[P]","subname":"Computer networking practical","semester":"6"},{"cid":"22","course_name":"ME","subcode":"ME-301","subname":"motar","semester":"3"},{"cid":"23","course_name":"ME","subcode":"ME-302","subname":"friction","semester":"3"},{"cid":"24","course_name":"ME","subcode":"ME-301[P]","subname":"motar practical","semester":"3"},{"cid":"25","course_name":"ME","subcode":"ME-302[P]","subname":"friction practical","semester":"3"},{"cid":"26","course_name":"CE","subcode":"CE-701","subname":"Design of hydraulic Structure","semester":"7"},{"cid":"27","course_name":"CE","subcode":"CE-702","subname":"Advances Structrued design 2","semester":"7"},{"cid":"28","course_name":"CE","subcode":"CE-701[P]","subname":"Design of hydraulic Structure practical","semester":"7"},{"cid":"29","course_name":"CE","subcode":"CE-702[P]","subname":"Advances Structrued design 2 practical","semester":"7"},{"cid":"45","course_name":"AU","subcode":"AU-502","subname":"AUTOMATION TOOL","semester":"1"}];
var arrIncludeCS = [];
for (let i = 0; i < arr.length; i++){
if( arr[i].course_name =="CS"){
arrIncludeCS.push(arr[i])
}
}
console.log(arrIncludeCS)
&#13;
运行代码段,您将看到一个新的JSON。