【发布时间】:2021-06-19 22:31:52
【问题描述】:
我有从 csv 文件中读取的 JSON 数据。我希望能够从所有对象中获取测试、结果,并在每个对象中匹配测试、结果并在其中包含指标数组。
[{
"Test": "GGT",
"Result": "High",
"Indicator": "Alcohol abuse Liver Disease"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Congestive Heart Failure"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: NSAIDs"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: Lipid lowering drugs"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: Antibiotics"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: Histamine Blockers"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: Antifungals"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: anticonvulsants"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: antidepressants"
}, {
"Test": "GGT",
"Result": "High",
"Indicator": "Drugs: testoserone"
}, {
"Test": "GGT",
"Result": "Low",
"Indicator": "No concern"
}, {
"Test": "GGT",
"Result": "Low",
"Indicator": "unlikely liver disease"
}, {
"Test": "GGT",
"Result": "Low",
"Indicator": "Drugs: Oral contraceptives"
}, {
"Test": "GGT",
"Result": "Low",
"Indicator": "Drugs: Clofibrate"
}, {
"Test": "AST",
"Result": "High",
"Indicator": "(if >10xULN) acute hepatitis"
}]
我希望能够像这样解析它
[
{
Test: "GGT",
Result: "High",
Indicators: [
"Alcohol abuse Liver Disease",
"Congestive Heart Failure",
"Drugs: NSAIDs",
"Drugs: Lipid lowering drugs",
"Drugs: Antibiotics",
"Drugs: Histamine Blockers",
],
},
{
Test: "GGT",
Result: "Low",
Indicators: ["unlikely liver disease", "Drugs: Oral contraceptives", "Drugs: Clofibrate"],
},
]
我跳过了结果中的记录,但我相信你明白了。我想将测试、结果键映射在一起并制作一个指标数组。请帮助我。
【问题讨论】:
标签: javascript node.js json reactjs