Reputation: 85
When the name is present, it will be enhanced with '' at the prefix and postfix, like '*Hello*'. However, if the name is absent, it adds only '**'. When the name is optional, how can I avoid adding only '**' when the request is absent? It is same for addressLine1, addressLine2 as well.
Updates: In the below request postalCode and tour properties should not be enhanced.
Input.json
{
"search": {
"party": {
"name": "AccountName",
"tour": "TourName"
},
"address": {
"addressLine1": "US",
"postalCode": "psCode"
}
}
}
JoltTransformation
[
{
"operation": "shift",
"spec": {
"search": {
"party": {
"name": "AccountName",
"tour": "Tour"
},
"address": {
"addressLine1": "add1",
"addressLine2": "add2",
"postalCode": "psCode"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"AccountName": "=concat('*',@(1,AccountName),'*')",
"add1": "=concat('*',@(1,add1),'*')",
"add2": "=concat('*',@(1,add2),'*')"
}
}
]
ActualOutput.json
{
"AccountName" : "*AccountName*",
"Tour" : "TourName",
"add1" : "*US*",
"add2" : "*UK*",
"psCode" : "psCode"
}
ActualdOutput.json : When addressLine2 is missing, it adds **
{
"AccountName" : "*AccountName*",
"Tour" : "TourName",
"add1" : "*US*",
"psCode" : "psCode",
"add2" : "**"
}
In the actual output I would like to eliminate "SecondaryRatings" : { } in the response
Upvotes: 1
Views: 65
Reputation: 65323
No need to add asteriskes individually, but do it in a generic way just by replacing the current modify spec with the following one :
{
"operation": "modify-overwrite-beta",
"spec": {
"*ame|add*": "=concat('*',@(1,&),'*')" // @(1,&) is a replacement for
// the current elements
}
}
by this the unwanted attributes will become extinct spontaneously and only related restricted attributes sets are impacted.
Upvotes: 1