最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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
          }
       }
    }   
发布评论

评论列表(0)

  1. 暂无评论