我有Lotash 4.17的空位
我的接口响应 struct 如下:
{
"things": [
{
"id": 14500,
"name": "Q1 Out Ind",
"thing_type_id": 6,
"owner_id": 1680,
"owner": {
"id": 1680,
"model_id": 602
},
"thing_type": {
"id": 6,
"name": "The Type of Thing"
},
"related_things": [
{
"id": 9749,
"name": "unnamed thing",
"thing_id": 14500,
"more_things": [
{
"id": 16166,
"name": "Num Thing Sum",
"datasource_object_id": 9408,
"thing_id": 9749,
"external_datasource": {
"id": 9408,
"parent_id": 2810,
"target_id": 15028
}
}
]
}
]
},
{
"id": 14503,
"name": "Q2 Out Ind",
"thing_type_id": 6,
"owner_id": 1681,
"owner": {
"id": 1681,
"model_id": 602
},
"thing_type": {
"id": 6,
"name": "The Type of Thing"
},
"related_things": [
{
"id": 9750,
"name": "unnamed thing2",
"thing_id": 14503,
"more_things": [
{
"id": 16167,
"name": "Num Thing Avg",
"datasource_object_id": 9409,
"thing_id": 9750,
"external_datasource": {
"id": 9409,
"parent_id": 2810,
"target_id": 15029
}
},
{
"id": 16168,
"name": "Num Thing Count",
"datasource_object_id": 9408,
"thing_id": 9750,
"external_datasource": {
"id": 9408,
"parent_id": 2810,
"target_id": 15028
}
}
]
}
]
}
]
}
我正在try 获取与嵌套末尾的特定target_id
相匹配的对象列表.
到目前为止,以下操作仅在数组中有一个结果时才起作用:
_.filter(things.things,
function (obj) {
return obj.related_things[0].more_things[0].external_datasource.target_id == 15028;
}
)
然而,正如您在本例中看到的,在本例中,它有两个"东西",在最后有一个匹配,因为有more_things
和related_things
的数组--我如何调整我的寄生过滤器来搜索任何深度?我需要匹配对象的列表,以在UI中显示与匹配目标相关的各种属性.