I am facing a problem, transforming a JSON .
Requirement is to concatenate only if my two columns are not Null, default value if any of one column is NULL
Input 1 :
[
{
"division_Code": "F",
"department_Code": "L3D4",
"department": "BABY ACCESSORIES"
}
]
Output Expected :
{
"PLMDepartment" : "FL3D4"
}
Input 2 :
[
{
"division_Code": "",
"department_Code": "L3D4",
"department": "BABY ACCESSORIES"
}
]
Output Expected :
{
"PLMDepartment" : "Invalid"
}
Input 3 :
[
{
"division_Code": "F",
"department_Code": "",
"department": "BABY ACCESSORIES"
}
]
Output Expected :
{
"PLMDepartment" : "Invalid"
}
Jolt spec I tried :
[
{
"operation": "modify-default-beta",
"spec": {
"*": {
"PLMDepartment": "=concat(@(1,division_Code),@(1,department_Code))"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"PLMDepartment": "PLMDepartment"
}
}
}
]
But its not coming as expected.
Pls help Can anyone who is a jolt expert, help me get the desired output. I think i m stuck in the last step
2
Answers
You can use conditionally return the desired result after determining whether one of those attributes has zero size such as
The below spec can do the trick with less number of functions.