我有一个数组(categorizedDatas),其中包含以下内容:
{
"4x4": {
"items": [
{
"Category": "4x4",
"Quantity": 1,
"packingLocation": "4x4",
"SubCategory": "ACCESSORIES",
"Name": "Rear seat",
"Brand": "TOYOTA",
"Qty": 1,
"Owner": "Shared",
"Status": "Ready",
"Weight": 31.5,
"RepairNotes": "",
"Kit": "",
"KitDetails": "",
"LoanedTo": "",
"StorageLocation": "SHED",
"id": "974e2e40-0c6b-11ec-90f3-ff0167255365"
},
{
"Category": "4x4",
"Quantity": 1,
"packingLocation": "4x4",
"SubCategory": "ACCESSORIES",
"Name": "Second row shelf - middle",
"Brand": "CUSTOM",
"Qty": 1,
"Owner": "Shared",
"Status": "Ready",
"Weight": 2,
"RepairNotes": "\nd\ndf\n\ndf\ndf\ndf\nd\nd\n\nd\ndf\ndfdf",
"Kit": "",
"KitDetails": "",
"LoanedTo": "",
"StorageLocation": "4x4",
"id": "97a37a30-0c6b-11ec-90f3-ff0167255365"
}
]
},
"Camper": {
"items": [
{
"Category": "4x4",
"Quantity": 1,
"packingLocation": "Camper",
"SubCategory": "FUEL STORAGE",
"Name": "Diesel Jerry Can 20L",
"Brand": "SCEPTER",
"Qty": 2,
"Owner": "Shared",
"Status": "Fill",
"Weight": 22.6,
"RepairNotes": "",
"Kit": "",
"KitDetails": "",
"LoanedTo": "",
"StorageLocation": "4x4",
"id": "92f3fbe0-0c6b-11ec-90f3-ff0167255365"
},
{
"Category": "4x4",
"Quantity": 1,
"packingLocation": "Camper",
"SubCategory": "ACCESSORIES",
"Name": "Second row shelf - top",
"Brand": "CUSTOM",
"Qty": 1,
"Owner": "Shared",
"Status": "Ready",
"Weight": 5.4,
"RepairNotes": "",
"Kit": "",
"KitDetails": "",
"LoanedTo": "",
"StorageLocation": "SHED",
"id": "97867c50-0c6b-11ec-90f3-ff0167255365"
}
]
}
}
我要做的是根据分区对重量字段求和(即,计算4x4以下的所有重量,并计算Camper下的所有重量).
我该怎么做呢,我已经试过了各种各样的修改.减少但都会返回一个错误,所以不确定我会错在哪里,或者这是否可能...