这是我的 json 的样子:
invoices = {
"count": 1 "data": Array(0)[{
"company": "ABC PLC",
"customer": {
"name": "XYZ"
},
"invoiceFees": Array(2)[
0: {
"quarter": {
"q_name": "A",
"description": "payments for quarter A"
}
},
1: {
"quarter": {
"q_name": "B",
"description": "payments for quarter B"
}
}
]
}]
}
我正在尝试按季度对发票结果进行分组。这就是我的做法:
console.log(_.groupBy(invoices.data.invoiceFees, 'quarter.q_name'));
这会将所有内容切成空结果,如下所示:
invoices = {}
我在这里做错了什么?
我想要的输出应该是这样的:
invoices = {
"data": [{
"company": "ABC PLC",
"customer": {
"name": "XYZ"
},
"invoiceFees": [{
"quarter A: {
"description": "payments for quarter A"
},
"quarter B: {
"description": "payments for quarter B"
}
}]
}]
}
长风秋雁
相关分类