json - Need jolt spec for condition based scenario - Stack Overflow

For this policies section in input json i need output json like this.if"policyType": "

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
          }
       }
    }   

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745288383a4620705.html

相关推荐

  • json - Need jolt spec for condition based scenario - Stack Overflow

    For this policies section in input json i need output json like this.if"policyType": "

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信