javascript - 对象数组过滤并获取另一个结构中的值
问题描述
我将数据作为对象数组,我应该过滤数据并获取具有值的对象和最小键,我尝试使用循环和过滤器,但我无法达到预期的效果。我已经分享了我拥有的数据和预期的结构,找到下面的代码,请帮助我。
我在下面的数据:
var data = [
{
"Id": 1392236,
"foldId": 410176,
"binding": [
{
"assayType": "binding",
"activityValue": 0.03,
"strId": 1392236
},
{
"assayType": "binding",
"activityValue": 5.0,
"strId": 1392236
}
],
"functional invitro": [
{
"assayType": "functional invitro",
"activityValue": 0.03,
"strId": 1392236
},
{
"assayType": "functional invitro",
"activityValue": 5.0,
"strId": 1392236
},
],
"functionalInvivo": [
{
"assayType": "functional invivo",
"activityValue": 45.0,
"strId": 1392236
},
{
"assayType": "functional invivo",
"activityValue": 54.0,
"strId": 1392236
}
],
"pharmacokinetics": [
{
"assayType": "pharmacokinetics",
"activityValue": 10.67,
"strId": 1392236
},
{
"assayType": "pharmacokinetics",
"activityValue": 2.6,
"strId": 1392236
}
]
},
{
"Id": 1392543,
"foldId": 410176,
"binding": [
{
"assayType": "binding",
"activityValue": 0.38,
"strId": 1392543
},
{
"assayType": "binding",
"activityValue": 4.3,
"strId": 1392543
}
],
"functional invitro": [
{
"assayType": "functional invitro",
"activityValue": 2.03,
"strId": 1392543
},
{
"assayType": "functional invitro",
"activityValue": 3.0,
"strId": 1392543
},
],
"functionalInvivo": [
{
"assayType": "functional invivo",
"activityValue": 25.0,
"strId": 1392543
},
{
"assayType": "functional invivo",
"activityValue": 64.0,
"strId": 1392543
}
],
"pharmacokinetics": [
{
"assayType": "pharmacokinetics",
"activityValue": 30.67,
"strId": 1392543
},
{
"assayType": "pharmacokinetics",
"activityValue": 5.6,
"strId": 1392543
}
]
}
]
过滤后期望如下:
var filterData = [
{
"assayType": "binding",
"activityValue": 0.03,
"strId": 1392543
},
{
"assayType": "functional invitro",
"activityValue": 5.0,
"strId": 1392543
},
{
"assayType": "binding",
"activityValue": 4.3,
"strId": 1392236
},
{
"assayType": "pharmacokinetics",
"activityValue": 6.06,
"strId": 1392543
},
{
"assayType": "functional invivo",
"activityValue": 64,
"strId": 1392543
},
{
"assayType": "functional invivo",
"activityValue": 4,
"strId": 1392236
},
{
"assayType": "pharmacokinetics",
"activityValue": 6.06,
"strId": 1392236
},
]
帮我解决。
解决方案
推荐阅读
- c# - .net Standard 2.0 类库在添加引用时产生错误
- kubernetes - 将自定义 jars 添加到 camel-k 集成
- c# - 修改列表中的vector3轴
- oracle - ORA-28234: 在 Oracle 中进行 AES 加密时密钥长度太短
- reactjs - 您好,我想在反应 js 中将项目从待办事项列表移动到完成列表这是我的代码
- python - 无法使用 pip main 安装 python 外部包
- r - 如何使用管道将数据框列作为参数传递给函数?
- node.js - 使用 Node js 在 LAN 上进行点对点连接
- java - spring sleuth - 标签和行李之间的区别
- rabbitmq - 如何关闭 Rabbitmq 连接