Need a jolt spec with only the mentioned field in output section.remaining fields are not required.As "date" is the field for which I need to populate the output json also need to check "date" is null or not depending on "type" we need to populate. I wrote the jolt which is only population either "date" or "type", but i need both
If inventory.release.date is not null, then "type":"ReleaseDate" If date is not present then check if inventory.release.days is not null or not 0 , then "type":"PriorToArrival"
Input json:
{
"inventory": {
"release": {
"date": "2025-01-16",
"days": 0,
"isRolling": true,
"value": "4gh",
"computationType": "Flat"
}
}
}
Output json:
{
"releaseSettings": {
"date": "2025-01-16",
"type":"ReleaseDate",
"isRolling": true
}
}
I assume that you want to chack if inventory.release.days
is not null and not 0 rather, then you can use the following transformation :
[
{
"operation": "modify-overwrite-beta",
"spec": {
"inventory": {
"release": {
"typeChk": ["=isPresent(@(1,date))", "PriorToArrival"] //set to "PriorToArrival" if "date" attribute doesn't exist
}
}
}
},
{
"operation": "shift",
"spec": {
"inventory": {
"release": {
"date|isRolling": "&1Settings.&",
"typeChk": {
"PriorToArrival": {
"@2,days": {
"0": {
"": ""
},
"*": { //if the value of "days" > 0
"@3": "&5Settings.type"
}
}
},
"*": { //if not set to "PriorToArrival" within the modify spec
"#ReleaseDate": "&3Settings.type"
}
}
}
}
}
}
]