JSON Input :
{
"code": "+91-",
"status": "A",
"number": "123456778",
"country": "I",
"pukcode": "00-766-54"
}
My Jolt Spec 1 :
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=trim",
"mobile": "=concat(@(1,code),@(1,number),"
}
},
{
"operation": "shift",
"spec": {
"eventInfo": "eventInfo",
"mobile": {
"": {
"comment": [
"if blank, do not pass mobile"
]
},
"*": {
"@(2,mobile)": "eventData.Records.[0].mobile",
"@(2,status)": {
"A": {
"#Active": "eventData.Records.[0].status"
}
},
"@(2,country)": {
"I": {
"#India": "eventData.Records.[0].country"
}
},
"@(2,pukcode)": {
"": {
"comment": [
"if blank, do not pass mobile"
]
},
"*": {
"@(2,pukcode)": "eventData.Records.[0].pukcode"
}
}
}
}
}
}
]
output :
{
"eventData" : {
"Records" : [ {
"mobile" : "+91-123456778",
"status" : "Active",
"country" : "India"
} ]
}
}
To the above Input I need to Populate the Data based on mobile number existence then only it should populate all the fields and puk-code code should also populate when input data is prasent in the input by target to mobile. But here the Problem pukcode is not getting populate even when the field consist Input data.
My Jolt Spec 2 :
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=trim",
"mobile": "=concat(@(1,code),@(1,number),"
}
},
{
"operation": "shift",
"spec": {
"eventInfo": "eventInfo",
"mobile": {
"": {
"comment": [
"if blank, do not pass mobile"
]
},
"*": {
"@(2,mobile)": "eventData.Records.[0].mobile",
"@(2,status)": {
"A": {
"#Active": "eventData.Records.[0].status"
}
},
"@(2,country)": {
"I": {
"#India": "eventData.Records.[0].country"
}
},
"@(2,pukcode)": {
"": {
"comment": [
"if blank, do not pass mobile"
]
},
"*": "eventData.Records.[0].pukcode"
}
}
}
}
}
]
Output 2 :
{
"eventData": {
"Records": [
{
"mobile": "+91-123456778",
"status": "Active",
"country": "India",
"pukcode": null
}
]
}
}
pls provide some solution to the above
Case 1 JSON Input :
{
"code": "+91-",
"status": "A",
"number": "123456778",
"country": "I",
"pukcode": "00-766-54"
}
Expected Output 1 :
{
"eventData": {
"Records": [
{
"mobile": "+91-123456778",
"status": "Active",
"country": "India",
"pukcode": "00-766-54"
}
]
}
}
Case 2 JSON Input :
{
"code": "",
"status": "A",
"number": "",
"country": "I",
"pukcode": "00-766-54"
}
Expected Output 2 :
null
You can use the following transformation specs :