将Parts中将具有相同id值的Demands数据合并到一起,其他不变。
输入:
{
"Parts": [{
"id": "12704",
"a": 0,
"Demands": [{
"Date": "2024-08-08T20:00:00.320+08:00",
"Qty": 80,
"Status": "4"
}]
},
{
"id": "12704",
"a": 0,
"Demands": [{
"Date": "2024-08-15T20:00:00.320+08:00",
"Qty": 120,
"Status": "4"
}]
},
{
"id": "12755",
"a": 1,
"Demands": [{
"Date": "2024-08-14T20:00:00.320+08:00",
"Qty": 100,
"Status": "6"
}]
},
{
"id": "12755",
"a": 1,
"Demands": [{
"Date": "2024-08-18T20:00:00.320+08:00",
"Qty": 60,
"Status": "5"
}]
},
{
"id": "12724",
"a": 1,
"Demands": [{
"Date": "2024-08-14T20:00:00.320+08:00",
"Qty": 120,
"Status": "5"
}]
}
}
输出:
{
"Parts": [{
"id": "12704",
"a": 0,
"Demands": [{
"Date": "2024-08-08T20:00:00.320+08:00",
"Qty": 80,
"Status": "4"
}, {
"Date": "2024-08-15T20:00:00.320+08:00",
"Qty": 120,
"Status": "4"
}]
},
{
"id": "12755",
"a": 1,
"Demands": [{
"Date": "2024-08-14T20:00:00.320+08:00",
"Qty": 100,
"Status": "6"
}, {
"Date": "2024-08-18T20:00:00.320+08:00",
"Qty": 60,
"Status": "5"
}]
},
{
"id": "12724",
"a": 1,
"Demands": [{
"Date": "2024-08-14T20:00:00.320+08:00",
"Qty": 120,
"Status": "5"
}]
}
}
搞了很久没弄出来,还请大神帮忙分析分析
相似问题