Reputation: 261
For this policies section in input json i need output json like this.
if "policyType": "CancellationPolicy" in input json, then in output json cancellationPolicy block will come like this.
"cancellationPolicy": {
"penalty":{
"cancellationFee": "100"
},
"deadline":{
"numberOfDays": 30,
"type": "AtBookingTime"
}
}
and if "policyType": "DepositPolicy" in input json, then in output json, DepositPolicy block will come like this. "DepositPolicy": { "numberOfNights": 30 }
Please help me with the jolt spec.
mapping are like this:
Penalty.monetaryAmount in input will be loaded to policies.cancellationPolicy.penalty.cancellationFee in output
Deadline.numberofDays in input will be loaded to policies.cancellationPolicy.deadline.numberOfDays in output
deadline.numberofDays in input will be loaded to policies.depositPolicy.numberOfNights.
and among all the "DepositPolicy" nodes in input json only minimum value of "numberOfNights" one should appear in output.
input json :
{
"policies": [
{
"policyType": "CancellationPolicy",
"level": "Pickup",
"penalty": {
"nightBasedAmount": "EqualToDeposit",
"monetaryAmount": "100"
},
"deadline": {
"type": "AtBookingTime",
"numberOfDays": 30
}
},
{
"policyType": "DepositPolicy",
"level": "Pickup",
"deadline": {
"numberOfDays": 12
}
},
{
"policyType": "DepositPolicy",
"level": "Group",
"penalty": {
"monetaryAmount": "100",
"currency": "VND"
},
"deadline": {
"numberOfDays": 30
}
},
{
"policyType": "DepositPolicy",
"level": "Group",
"penalty": {
"monetaryAmount": "100",
"currency": "VND"
},
"deadline": {
"numberOfDays": 20
}
},
{
"policyType": "DepositPolicy",
"level": "Group",
"penalty": {
"monetaryAmount": "100",
"currency": "VND"
},
"deadline": {
"numberOfDays": 10
}
}
]
}
output josn:
{
"policies": {
"cancellationTime": "18:00:00",
"isGuaranteeRequired": true,
"cancellationPolicy": {
"penalty": {
"cancellationFee": "100"
},
"deadline": {
"numberOfDays": 30,
"type": "AtBookingTime"
}
},
"DepositPolicy": {
"numberOfNights": 10
}
}
}
Upvotes: 0
Views: 42