gpt4 book ai didi

javascript - 按键名过滤 JSON 数据

转载 作者:行者123 更新时间:2023-11-30 16:20:15 24 4
gpt4 key购买 nike

我是 angularJS 的新手

我有这样的 JSON 数据:

[
{
"REPORT_ID": "QDP56DSC4BK",
"REPORT_NAME": "non, lobortis quis, pede.",
"REPORT_STATUS": 1,
"REPORT_TYPE": "Duis Sit Amet Ltd",
"REPORT_DATE": "Sep 3, 2015",
"REPORT_INGREDIENT_1": "Prednisone",
"REPORT_INGREDIENT_2": "Alprazolam",
"REPORT_INGREDIENT_3": "Prednisone",

},
{
"REPORT_ID": "JQY45UOQ8PY",
"REPORT_NAME": "Cras dolor dolor, tempus",
"REPORT_STATUS": 4,
"REPORT_TYPE": "Sociis Incorporated",
"REPORT_DATE": "Apr 26, 2015",
"REPORT_INGREDIENT_1": "Clonazepam",
"REPORT_INGREDIENT_2": "Hydrocodone/APAP",
"REPORT_INGREDIENT_3": "Nuvaring",
},
{
"REPORT_ID": "EDE42OUH3FM",
"REPORT_NAME": "posuere cubilia Curae; Donec",
"REPORT_STATUS": 5,
"REPORT_TYPE": "Pede Inc.",
"REPORT_DATE": "May 22, 2015",
"REPORT_INGREDIENT_1": "Furosemide",
"REPORT_INGREDIENT_2": "Lipitor",
"REPORT_INGREDIENT_3": "Losartan Potassium",

},
{
"REPORT_ID": "BWQ55EIS6LS",
"REPORT_NAME": "enim. Nunc ut erat.",
"REPORT_STATUS": 1,
"REPORT_TYPE": "Orci Sem Institute",
"REPORT_DATE": "Dec 29, 2015",
"REPORT_INGREDIENT_1": "Alprazolam",
"REPORT_INGREDIENT_2": "Celebrex",
"REPORT_INGREDIENT_3": "Promethazine HCl",
}
]

如何过滤此数据并将所有“REPORT_STATUS”数据存储在单独的数组中。

我的数组应该包含:[“REPORT_STATUS”:1,“REPORT_STATUS”:4,“REPORT_STATUS”:5,“REPORT_STATUS”:1]

最佳答案

让我们一起玩 builded functionality :

console.log(JSON.stringify(json, ['REPORT_STATUS']));

会产生

[{"REPORT_STATUS":1},{"REPORT_STATUS":4},{"REPORT_STATUS":5},{"REPORT_STATUS":1}]

关于javascript - 按键名过滤 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34850075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com