我有以下JSON结构,我想提取有关给定id的特定团队的所有信息,包括它所属的部门。
{
"teams":[
{
"divisionName":"5th Grade - Green",
"divisionTeams":[
{
"id":3222,
"name":"Columbia Ravens 5th",
"coach":"John Miller"
},
{
"id":3220,
"name":"HC Elite OMalley 5th",
"coach":"Eddie OMalley"
}
]
},
{
"divisionName":"5th Grade - White",
"divisionTeams":[
{
"id":3225,
"name":"CBSA Hoyas 5th Grade",
"coach":"Terrance Taylor"
},
{
"id":3276,
"name":"HC Elite 4th Tookes",
"coach":"Anthony Tookes"
},
]
}
] }
我尝试使用以下lodash代码,但它是未定义的。
var team=_.chain(data.teams)
.flatten("divisionTeams")
.find({"id":3222 })
.value();
console.log(team);
非常感谢任何帮助。