使用Javascript将JSON对象属性提取到新数组中

使用Javascript将JSON对象属性提取到新数组中,javascript,arrays,json,Javascript,Arrays,Json,我有超过100个JSON对象,其格式如下: { "grants":[ { "grant":0, "ID": "EP/E027261/1", "Title": "Semiconductor Research at the Materials-Device Interface", "PIID": "6674", "Scheme": "Platform Grants", "StartDate": "01/05/2007", "EndDate":

我有超过100个JSON对象,其格式如下:

{
"grants":[
{
    "grant":0,
    "ID": "EP/E027261/1",
    "Title": "Semiconductor Research at the Materials-Device Interface",
    "PIID": "6674",
    "Scheme": "Platform Grants",
    "StartDate": "01/05/2007",
    "EndDate": "31/10/2012",
    "Value": "800579"
}, ... more grants
我希望能够将EndDate和值捕获到一个新数组中。类似于下面的输出

"extractedGrants":[
{
    "EndDate": "31/10/2012",
    "Value": "800579"
}, ... more extracted objects with EndDate and Value properties.
我认为正确的方法是使用array.map(函数(a){});但是我无法在函数中获得正确的代码


谢谢。

您可以对结果数组使用对象销毁和新对象

var object={grant:[{grant:0,ID:“EP/E027261/1”,标题:“材料-设备界面的半导体研究”,PIID:“6674”,计划:“平台资助”,起始日期:“01/05/2007”,结束日期:“31/10/2012”,价值:“800579”},
result=object.grants.map(({EndDate,Value})=>({EndDate,Value}));

控制台日志(结果)太好了!谢谢