1

I need to maintain a category to category relation here where the resort should have its parent as destination, destination should have parent as region if region is present or it should have its parent as country

{
    "test": {
        "hierarchy": [
            {
                "locationId": "1234xyz",
                "name": "BLR",
                "type": "RESORT",
                "level": "RESORT",
                "countryCode": null
            },
            {
                "locationId": "2345cvb",
                "name": "KAR",
                "type": "DESTINATION",
                "level": "DESTINATION",
                "countryCode": null
            },
            {
                "locationId": "3456vbn",
                "name": "CAN",
                "type": "REGION",
                "level": "OVER_DESTINATIONS",
                "countryCode": null
            },
            {
                "locationId": "567nml",
                "name": "SPN",
                "type": "COUNTRY",
                "level": "COUNTRY",
                "countryCode": "ES"
            }
        ]
    }
}

$.test.hierarchy.[?(@.type=='REGION' || @.type=='COUNTRY')].locationId

[
   "3456vbn",
   "567nml"
]

I am getting output as shown above, but expected output is i need if REGION is present in that case the output should have only REGION Location ID, it should not return COUNTRY Location ID, if REGION is NULL in that case it should return COUNTRY Location ID.

this expression works when region is absent . but when region is present we get two values region and country ,but here i want only region value.

sorifiend
  • 5,927
  • 1
  • 28
  • 45
Sandeep
  • 11
  • 1

0 Answers0