我需要使用JOLT转换将下面的输入转换为精确的输出。 输入:
{
"First_Name": "Test",
"Last_Name": "User",
"allpointofInterest": "someText",
"campaign_id": "123456789",
"lead_id": "123456789"
}
输出:
"input" : {
"tokens" : [ {
"name" : "{{my.First_Name}}",
"value" : "Test"
}, {
"name" : "{{my.Last_Name}}",
"value" : "User"
}, {
"name" : "{{my.allpointofInterest}}",
"value" : "someText"
} ]
},
"leads": [{
"id": "123456789"
}]
}
我尝试使用以下规格,但没有获得确切的输出。 规格:
[
{
"operation": "remove",
"spec": {
"campaign_id": ""
}
}, {
"operation": "shift",
"spec": {
"lead_id": {
"@": "input.leads[#1].id"
},
"*": "temptoken.&"
}
}, {
"operation": "shift",
"spec": {
"*": "&",
"temptoken": {
"*": {
"$": "input.tokens[#2].tmpname",
"@": "input.tokens[#2].value"
}
}
}
}, {
"operation": "modify-overwrite-beta",
"spec": {
"input": {
"leads": {
"*": {
"id": ["=toInteger", 0]
}
}
}
}
}, {
"operation": "modify-default-beta",
"spec": {
"input": {
"tokens": {
"*": {
"name": "=concat('{{my.',@(1,tmpname), '}}')"
}
}
}
}
}, {
"operation": "remove",
"spec": {
"input": {
"tokens": {
"*": {
"tmpname": ""
}
}
}
}
}
]
任何帮助将不胜感激。谢谢
答案 0 :(得分:0)
这样适合您吗?
[
{
"operation": "shift",
"spec": {
"#{{my.First_Name}}": "input.tokens[0].name",
"First_Name": "input.tokens[0].value",
"#{{my.Last_Name}}": "input.tokens[1].name",
"Last_Name": "input.tokens[1].value",
"#{{my.allpointofInterest}}": "input.tokens[2].name",
"allpointofInterest": "input.tokens[2].value",
"lead_id": "leads[#].id"
}
}
]