[英]Jolt Json transformation: Using value of an attribute to filter on a key
I am trying to transform a Json Using Jolt transformation looking for some input here.我正在尝试使用 Jolt 转换在此处寻找一些输入来转换 Json。 I am trying to filter on a Key which is a value of another attribute.我正在尝试过滤作为另一个属性值的键。 here is my input and expected output这是我的输入和预期 output
{
"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",
"name": "participantAgent1",
"joinTime": 1617634022303,
"type":"Agent"
}
}
},
"interactionId": "c5804d49-961d-11eb-9650-7fb32f44d8a5"
}
And the Output i am looking at is我正在看的 Output 是
{
"pid": "p1@gmail.com",
"name": "participantAgent1",
"joinTime": 1617634021103,
"type":"Agent"
}
and the spec that i tried with is我尝试过的规格是
[
{
"operation": "shift",
"spec": {
"participants": {
"@(2,pid)": {
"@(3,pid)": "pid",
"pType": "type",
"name": "name",
"joinTime":"joinTime"
}
}
}
}
]
But i am not getting expected output.但我没有预料到 output。 I tried with few other combination too but failed to get correct output.Can some one please help in this?我也尝试了其他一些组合,但未能得到正确的 output。有人可以帮忙吗?
[ // 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"
}
}
}
}
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.