Conditions in YAML to easily convert it as JSON

Viewed 19

I am struck somewhere and maybe even someone else looking into this kind of thing in future

actually, I have a requirement to convert YAML to JSON and its working fine but the problem is with **YAML Conditions ** For example, my YAML code is like this

variables:
  - name: isSaltWater
    "${{ if eq(parameters.WaterBody, 'Ocean')}}":
      value: SaltWater
    "${{  else }}":
      value: NormalWater

Now if I convert it to JSON it's coming like this

{
  "variables": [
    {
      "name": "isSaltWater",
      "${{ if eq(parameters.WaterBody, 'Ocean')}}": {
        "value": "SaltWater"
      },
      "${{  else }}": {
        "value": "NormalWater"
      }
    }
  ]
}

so is there any way in YAML to do it in another way so that even if someone creating objects out of JSON will be helpful

Question is how to handle if else conditions in JSON ?

please let me know if someone can help me

0 Answers
Related