0
我的angular4項目中有這個json對象。我想根據公共屬性對該對象進行分組或合併。如何根據angular4項目中的公共屬性對我的json對象進行分組或合併
如何基於fixture_desc合併這些對象?我想顯示爲fixture_desc =「百事可樂冷卻器」,並在其下的所有項目。
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler",
"min": 2,
"max": 8,
"_id": "58feb29a3a5c560011b1b96c"
},
{
"barcode": "052000328684",
"price": 2,
"taxable": false,
"description": "Gatorade Lemon Lime ",
"tax_rate": 0,
"inventory": 4,
"fixture_desc": "Pepsi Cooler",
"min": 1,
"max": 4,
}
]
我想使組織顯示我的數據。我預期的結果是這樣的:
"items": [
{
"name": "Pepsi Cooler」,
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
}
]
}
{
"name": 「Cook Cooler」,
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Cook Cooler
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Cook Cooler
}
]
}
]
你能提供預期的結果嗎? – Myonara
@Myonara我更新了我的問題,請檢查它。謝謝。 –