首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用jolt如何在数组中依靠id字段是否相同进行合并?

使用jolt如何在数组中依靠id字段是否相同进行合并?

提问于 2024-07-24 17:27:07
回答 0关注 0查看 30

将Parts中将具有相同id值的Demands数据合并到一起,其他不变。

输入:

代码语言:javascript
复制
{
	"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"
			}]
		}
	}

输出:

代码语言:javascript
复制
{
	"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"
			}]
		}
	}

搞了很久没弄出来,还请大神帮忙分析分析

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档