如何解决Jolt Json 转换:使用属性值过滤键
我正在尝试使用 Jolt 转换来转换 Json,在这里寻找一些输入。 我试图过滤一个键,它是另一个属性的值。这是我的输入和预期输出
{
"pid": "p1@gmail.com","eventType": "new","details": {
"participants": {
"automationqaus@gmail.com": {
"id": "automationqaus@gmail.com","type": "Customer"
},"p1@gmail.com": {
"id": "p1@gmail.com","name": "participantAgent1","joinTime": 1617634021103,"type":"Agent"
},"p2@gmail.com": {
"id": "p2@gmail.com","joinTime": 1617634022303,"type":"Agent"
}
}
},"interactionId": "c5804d49-961d-11eb-9650-7fb32f44d8a5"
}
我正在查看的输出是
{
"pid": "p1@gmail.com","type":"Agent"
}
我尝试使用的规范是
[
{
"operation": "shift","spec": {
"participants": {
"@(2,pid)": {
"@(3,pid)": "pid","pType": "type","name": "name","joinTime":"joinTime"
}
}
}
}
]
但是我没有得到预期的输出。我也尝试了其他几种组合,但未能获得正确的输出。有人可以帮忙吗?
解决方法
[ // converting the matching value as the key to the value of the details.
{
"operation": "shift","spec": {
"details": "@(1,pid)"
}
},{
"operation": "shift","spec": {
"*": {
"participants": {
"&1": { // matching with the target converted key
"id": "pid","type": "type","name": "name","joinTime": "joinTime"
}
}
}
}
}
]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。