I have three scenarios:
Scenario 1: When Fee1 has a value and Fee2 is "", output attribute FinalFee should have Fee1 value
Scenario 2: When Fee1 is "" and Fee2 has a value, output attribute FinalFee should have Fee2 value
Scenario 1: When Fee1 has a value and Fee2 has a value, output attribute FinalFee should have Fee1 value
Input:
{
"school": [
{
"schoolCode": ["SH","MA","KR"],
"fee1": [3,"",5],
"fee2": ["",10,15]
}
]
}
Expected Output:
{
"school": [
{
"schoolCode": "SH",
"finalFee": 3
},
{
"schoolCode": "MA",
"finalFee": 10
},
{
"schoolCode": "KR",
"finalFee": 5
}
]
}
All 3 scenarios are mentioned in the input, how to write the jolt operation for this. ifNull and ifEmpty functions did not work.
This is the spec operation I am trying to update
[
{
"operation": "shift",
"spec": {
"*": "&",
"school": {
"*": {
"schoolCode": {
"*": {
"@": [
"school.[#2].schoolCode"
]
}
},
"fee1": {
"*": {
"@": [
"school.[#2].finalFee"
]
}
},
"fee2": {
"*": {
"@": [
"school.[#2].finalFee"
]
}
}
}
}
}
}
]
2
Answers
Hi Shobika you can try this spec :
In first shift we are seperating each object of school array.
In Second shift addding a logic of Scenario 1 & Scenario 2.
And last operation cardinality will resolve Scenario 3 where it will pick value of finalFee from fee1 if both values are coming.
You can use the folowing transformation spec :
Refer this page for Elvis Operator