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

json - Need condition based jolt spec (ifelse) - Stack Overflow

programmeradmin0浏览0评论

Need a jolt spec where body.Contract.stayRestrictions[].restrictionType="ClosedToArrival"

populate body.Block.stayRestrictions[].isClosedToArrival=true else populate false

input JSON :

{
  "body": {
    "Contract": {
      "stayRestrictions": [
        {
          "restrictionType": "ClosedToArrival"
        }
      ]
    }
  }
}

output JSON:

{
  "body": {
    "Block": {
      "stayRestriction": [
        {
          "isClosedToArrival": "true"
        }
      ]
    }
  }
}

Need a jolt spec where body.Contract.stayRestrictions[].restrictionType="ClosedToArrival"

populate body.Block.stayRestrictions[].isClosedToArrival=true else populate false

input JSON :

{
  "body": {
    "Contract": {
      "stayRestrictions": [
        {
          "restrictionType": "ClosedToArrival"
        }
      ]
    }
  }
}

output JSON:

{
  "body": {
    "Block": {
      "stayRestriction": [
        {
          "isClosedToArrival": "true"
        }
      ]
    }
  }
}
Share Improve this question edited Feb 6 at 16:24 Barbaros Özhan 65.3k11 gold badges36 silver badges61 bronze badges asked Feb 6 at 15:57 OptimizerOptimizer 2611 gold badge2 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You can use the conditional logic under "restrictionType" object within the following spec such as

[
  {
    "operation": "shift",
    "spec": {
      "body": {
        "Contract": {
          "stayRestrictions": {
            "*": {
              "restrictionType": {
                "ClosedToArrival": {
                  "#true": "&6.&5.&4[&3].is&1"
                },
                "*": {//else case
                  "#false": "&6.&5.&4[&3].is&1"
                }
              }
            }
          }
        }
      }
    }
  }
]
发布评论

评论列表(0)

  1. 暂无评论