Input:
[
{
"policy": "Name",
"PAFrstNm": "John"
},
{
"PALastNm": "Jammy",
"policy": "Name"
},
{
"PAMiNm": "T",
"policy": "Name"
},
{
"policy": "Name",
"PPFrstNm": "sam"
},
{
"policy": "Name",
"PPLastNm": "jim"
},
{
"policy": "Name",
"PPMiNm": "E"
},
{
"policy": "Name",
"PPFrstNm1": "jun"
},
{
"policy": "Other",
"Summer": "533A"
},
{
"policy": "Other",
"Winter": "588A"
},
{
"PPLastNm1": "san",
"policy": "Name"
},
{
"PPMiNm1": "e",
"policy": "Name"
}
]
Ouput needed:
[
{
"PAfullnam": "John T Jammy",
"policy": "Name"
},
{
"PPfullnam": "sam E jim",
"policy": "Name"
},
{
"PPfullnam1": "jun e san",
"policy": "Name"
},
{
"Session": "533A 588A ",
"policy": "Other"
}
]
Jolt spec tried:
[
{
"operation": "shift",
"spec": {
"*": {
"LastN|FrstN|MiN": "@1,policy.&(0,1)fullna&(0,2)"
// the order of the part above is not important
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"0|2|1": "&2.&1.[#1]"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"ful": "=join(' ',@(1,&))",
"Session": "=concat(@(1,Summer),' ',@(1,Winter))"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"@": "[#2].&",
"$1": "[#2].policy"
}
}
}
}
]
You can start with adding new key-value pair into the first spec :
"*er": "@1,policy.SWfullname"
proper to Winter and Summer and go on like this :
[
{
"operation": "shift",
"spec": {
"*": {
"*LastN*|*FrstN*|*MiN*": "@1,policy.&(0,1)fullna&(0,2)",
"*er": "@1,policy.SWfullname"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"0|2|1": "&2.&1.[#1]"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"*": "=join(' ',@(1,&))"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"@": "&2_&1.&",
"$1": "&2_&1.policy"
}
}
}
},
{
"operation": "shift",
"spec": {
"*": "[]"
}
}
]