I have this JSON input:
{
"entityType": "job",
"id": 908815,
"properties": {
"AvatureID": 908815,
"TemplateName": [
"jicofo package",
"jitsi meet fork",
"jitsi-videobridge2 package"
],
"CaseType": [
"Internal project",
"Internal project",
"Internal project"
],
"ProjectType": [
"Cloud Services",
"Development",
"Cloud Services"
],
"Team": [
"Cloud Operations",
"Video",
"Cloud Operations"
],
"Category": [
"Routine Ops",
"Platform enhancement",
"Routine Ops"
],
"WorkflowStepID": [
"579",
"531",
"579"
]
}
}
And I need to get this output using a JOLT (v.0.1.1) transformation:
[
{
"ParentCaseID": 908815,
"TemplateName": "jicofo package",
"CaseType": "Internal project",
"ProjectType": "Cloud Services",
"Team": "Cloud Operations",
"Category": "Routine Ops",
"WorkflowStepID": "579"
},
{
"ParentCaseID": 908815,
"TemplateName": "jitsi meet fork",
"CaseType": "Internal project",
"ProjectType": "Development",
"Team": "Video",
"Category": "Platform enhancement",
"WorkflowStepID": "531"
},
{
"ParentCaseID": 908815,
"TemplateName": "jitsi-videobridge2 package",
"CaseType": "Internal project",
"ProjectType": "Cloud Services",
"Team": "Cloud Operations",
"Category": "Routine Ops",
"WorkflowStepID": "579"
}
]
But I am having some issues when I try to add the ParentCaseID
.
I am currently using this JOLT:
[
{
"operation": "shift",
"spec": {
"*": {
"TemplateName": {
"*": {
"@": "[&1].TemplateName"
}
},
"CaseType": {
"*": {
"@": "[&1].CaseType"
}
},
"ProjectType": {
"*": {
"@": "[&1].ProjectType"
}
},
"Team": {
"*": {
"@": "[&1].Team"
}
},
"Category": {
"*": {
"@": "[&1].Category"
}
},
"WorkflowStepID": {
"*": {
"@": "[&1].WorkflowStepID"
}
}
}
}
}
]
And its output is the next one:
[
{
"TemplateName": "jicofo package",
"CaseType": "Internal project",
"ProjectType": "Cloud Services",
"Team": "Cloud Operations",
"Category": "Routine Ops",
"WorkflowStepID": "579"
},
{
"TemplateName": "jitsi meet fork",
"CaseType": "Internal project",
"ProjectType": "Development",
"Team": "Video",
"Category": "Platform enhancement",
"WorkflowStepID": "531"
},
{
"TemplateName": "jitsi-videobridge2 package",
"CaseType": "Internal project",
"ProjectType": "Cloud Services",
"Team": "Cloud Operations",
"Category": "Routine Ops",
"WorkflowStepID": "579"
}
]
Is there any modification I can make to that JOLT so I can achieve the results I am looking for?
Thank you in advance!
2
Answers
What is the problem when adding the ParentCaseID? I tried the following and it worked:
Hope that works for you.
You can combine those separate objects into single representation as in the following shift transformation, and then only pick the single values for the ones with repeated values ("ParentCaseID" array in this case) by using cardinality transformation such as
the demo on the site https://jolt-demo.appspot.com/ is :