Есть ли простой способ в javascript (работающий на nodejs) объединять различные атрибуты объекта в массиве? Я знаю, что могу сделать это, используя некоторые for loop & et c, но мне было интересно, есть ли более простой способ. Мой массив объектов выглядит так -
[
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Tom",
"category_rank": 78,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Dick",
"category_rank": 103,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Harry",
"category_rank": 267,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Tom",
"category_rank": 42,
"date_of_extraction": "2020-04-20"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Dick",
"category_rank": 60,
"date_of_extraction": "2020-04-20"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Harry",
"category_rank": 132,
"date_of_extraction": "2020-04-20"
}
}
]
И я бы хотел, чтобы они были объединены следующим образом на основе date_of_extraction
[
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank":[
{
"category_name": "Tom",
"category_rank": 78,
"date_of_extraction": "2020-07-04"
},
{
"category_name": "Dick",
"category_rank": 103,
"date_of_extraction": "2020-07-04"
},
{
"category_name": "Harry",
"category_rank": 267,
"date_of_extraction": "2020-07-04"
}
]
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": [
{
"category_name": "Tom",
"category_rank": 42,
"date_of_extraction": "2020-04-20"
},
{
"category_name": "Dick",
"category_rank": 60,
"date_of_extraction": "2020-04-20"
},
{
"category_name": "Harry",
"category_rank": 132,
"date_of_extraction": "2020-04-20"
}
]
}
]